Modified: database.py

This commit is contained in:
hok7z 2023-04-16 16:11:08 +03:00
parent 6121d5a3ff
commit 652ec5a242
1 changed files with 13 additions and 10 deletions

View File

@ -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,18 +28,19 @@ class Member(Model):
joined = DateField(default=date.today())
class Meta:
db_table = "members"
database = db
class Message(Model):
user = ForeignKeyField(Member,lazy_load=True)
user = ForeignKeyField(Member, lazy_load=True)
timestamp = DateTimeField(default=datetime.now())
class Meta:
db_table = "messages"
database = db
def build_database():
db.create_tables([WebUser,Message])
db.create_tables([WebUser, Message])