mirror of
https://github.com/xlorepdarkhelm/numinar-coding-project.git
synced 2026-09-09 17:45:35 -04:00
@@ -9,7 +9,7 @@ from sqlalchemy import Connection
|
||||
from sqlalchemy import pool
|
||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
||||
|
||||
from backend.db import db_url
|
||||
from backend.db import DB_URL
|
||||
from backend.models import Base
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ def run_migrations_offline():
|
||||
script output.
|
||||
"""
|
||||
# url = config.get_main_option("sqlalchemy.url")
|
||||
url = db_url
|
||||
url = DB_URL
|
||||
context.configure(
|
||||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
@@ -63,7 +63,7 @@ async def run_migrations_online():
|
||||
and associate a connection with the context.
|
||||
"""
|
||||
configuration = cast(dict[str, str], config.get_section(config.config_ini_section))
|
||||
configuration["sqlalchemy.url"] = db_url
|
||||
configuration["sqlalchemy.url"] = DB_URL
|
||||
connectable = async_engine_from_config(
|
||||
configuration,
|
||||
prefix="sqlalchemy.",
|
||||
|
||||
@@ -6,15 +6,15 @@ from backend import config
|
||||
|
||||
|
||||
# Database URL configuration
|
||||
pg_user = config("POSTGRES_USER", default="user")
|
||||
pg_password = config("POSTGRES_PASSWORD", default="password")
|
||||
pg_db = config("POSTGRES_DB", default="mydb")
|
||||
pg_host = config("POSTGRES_HOST", default="postgres")
|
||||
pg_port = config("POSTGRES_PORT", default="5432")
|
||||
db_url = f"postgresql+asyncpg://{pg_user}:{pg_password}@{pg_host}:{pg_port}/{pg_db}"
|
||||
PG_USER = config("POSTGRES_USER", default="user")
|
||||
PG_PASSWORD = config("POSTGRES_PASSWORD", default="password")
|
||||
PG_DB = config("POSTGRES_DB", default="mydb")
|
||||
PG_HOST = config("POSTGRES_HOST", default="postgres")
|
||||
PG_PORT = config("POSTGRES_PORT", default="5432")
|
||||
DB_URL = f"postgresql+asyncpg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}"
|
||||
|
||||
# Set the echo parameter based on the environment, other environments can be added as needed
|
||||
echo = config("ENVIRONMENT", default="development") in {"development"}
|
||||
ECHO = config("ENVIRONMENT", default="development") in {"development"}
|
||||
|
||||
# Create the async engine
|
||||
engine = create_async_engine(db_url, echo=echo)
|
||||
engine = create_async_engine(DB_URL, echo=ECHO)
|
||||
|
||||
Reference in New Issue
Block a user