mirror of
https://github.com/creyD/creyPY.git
synced 2026-04-15 04:40:36 +02:00
feat: added common database helper
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
from .async_session import * # noqa
|
||||
from .helpers import * # noqa
|
||||
from .session import * # noqa
|
||||
from .async_session import * # noqa
|
||||
|
||||
8
creyPY/fastapi/db/helpers.py
Normal file
8
creyPY/fastapi/db/helpers.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from sqlalchemy_utils import create_database, database_exists
|
||||
|
||||
|
||||
def create_if_not_exists(db_name: str):
|
||||
from .common import SQLALCHEMY_DATABASE_URL
|
||||
|
||||
if not database_exists(SQLALCHEMY_DATABASE_URL + db_name):
|
||||
create_database(SQLALCHEMY_DATABASE_URL + db_name)
|
||||
Reference in New Issue
Block a user