mirror of
https://github.com/creyD/creyPY.git
synced 2026-04-12 19:30:30 +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 .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)
|
||||||
@@ -11,6 +11,7 @@ starlette>=0.37.2 # FastAPI
|
|||||||
|
|
||||||
fastapi-pagination>=0.12.26 # Pagination
|
fastapi-pagination>=0.12.26 # Pagination
|
||||||
sqlalchemy>=2.0.31 # SQLAlchemy
|
sqlalchemy>=2.0.31 # SQLAlchemy
|
||||||
|
sqlalchemy-utils==0.41.2 # For managing databases
|
||||||
|
|
||||||
python-dotenv>=1.0.1 # Environment variables
|
python-dotenv>=1.0.1 # Environment variables
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user