Modified: database.py
This commit is contained in:
parent
6121d5a3ff
commit
652ec5a242
|
@ -1,12 +1,13 @@
|
|||
from peewee import DateTimeField, ForeignKeyField, Model, CharField, BigIntegerField, DateField
|
||||
from peewee import Model
|
||||
from peewee import BigIntegerField, CharField, DateTimeField, DateField, ForeignKeyField
|
||||
from playhouse.db_url import connect
|
||||
|
||||
from datetime import date, datetime
|
||||
from config import db_url
|
||||
|
||||
|
||||
db = connect(db_url)
|
||||
|
||||
|
||||
class WebUser(Model):
|
||||
username = CharField()
|
||||
password_hash = CharField()
|
||||
|
@ -15,6 +16,7 @@ class WebUser(Model):
|
|||
db_table = "webusers"
|
||||
database = db
|
||||
|
||||
|
||||
class Member(Model):
|
||||
user_id = BigIntegerField()
|
||||
first_name = CharField()
|
||||
|
@ -26,11 +28,11 @@ class Member(Model):
|
|||
|
||||
joined = DateField(default=date.today())
|
||||
|
||||
|
||||
class Meta:
|
||||
db_table = "members"
|
||||
database = db
|
||||
|
||||
|
||||
class Message(Model):
|
||||
user = ForeignKeyField(Member, lazy_load=True)
|
||||
timestamp = DateTimeField(default=datetime.now())
|
||||
|
@ -39,5 +41,6 @@ class Message(Model):
|
|||
db_table = "messages"
|
||||
database = db
|
||||
|
||||
|
||||
def build_database():
|
||||
db.create_tables([WebUser, Message])
|
||||
|
|
Loading…
Reference in New Issue