You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
653 B
Python
24 lines
653 B
Python
from peewee import Model, UUIDField, DateTimeField
|
|
from datetime import datetime
|
|
from uuid import uuid4
|
|
|
|
from database.config import DATABASE_TYPE
|
|
from database.connection.postgres import get_postgres_database
|
|
from database.connection.sqlite import get_sqlite_database
|
|
|
|
|
|
# Establish connection to the database
|
|
if DATABASE_TYPE == "postgres":
|
|
database = get_postgres_database()
|
|
else:
|
|
database = get_sqlite_database()
|
|
|
|
|
|
class BaseModel(Model):
|
|
id = UUIDField(primary_key=True, default=uuid4)
|
|
created_at = DateTimeField(default=datetime.now)
|
|
updated_at = DateTimeField(default=datetime.now)
|
|
|
|
class Meta:
|
|
database = database
|