feat: added common database helper

This commit is contained in:
2024-11-24 18:01:45 +01:00
parent 481bfcfffd
commit 7dbce117c8
3 changed files with 11 additions and 1 deletions

View File

@@ -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

View 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)

View File

@@ -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