mirror of
https://github.com/sigmasternchen/Diary
synced 2025-03-15 07:08:56 +00:00
Changed User class, added Diary and Entry class
This commit is contained in:
parent
d3884a781d
commit
5299fdd309
1 changed files with 25 additions and 1 deletions
26
models.py
26
models.py
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
from sqlalchemy import Column,Integer,String
|
import datetime
|
||||||
|
|
||||||
|
from sqlalchemy import Column,Integer,String,Date
|
||||||
from database import Base
|
from database import Base
|
||||||
|
|
||||||
class User(Base):
|
class User(Base):
|
||||||
|
@ -12,3 +14,25 @@ class User(Base):
|
||||||
def __init__(self,username,password):
|
def __init__(self,username,password):
|
||||||
self.username=username
|
self.username=username
|
||||||
self.password=password
|
self.password=password
|
||||||
|
|
||||||
|
class Diary(Base):
|
||||||
|
__tablename__='diaries'
|
||||||
|
id=Column(Integer(),primary_key=True,unique=True)
|
||||||
|
owner=Column(Integer())
|
||||||
|
name=Column(String(256),unique=True)
|
||||||
|
|
||||||
|
def __init__(self,owner,name):
|
||||||
|
self.owner=owner
|
||||||
|
self.name=name
|
||||||
|
|
||||||
|
class Entry(Base):
|
||||||
|
__tablename__='entries'
|
||||||
|
id=Column(Integer(),primary_key=True,unique=True)
|
||||||
|
diary=Column(Integer())
|
||||||
|
date=Column(Date())
|
||||||
|
text=Column(String(8192))
|
||||||
|
|
||||||
|
def __init__(self,diary,text):
|
||||||
|
self.diary=diary
|
||||||
|
self.text=text
|
||||||
|
self.date=datetime.datetime.now().strftime("%Y-%m-%d")
|
||||||
|
|
Loading…
Reference in a new issue