-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docker compose & make db session async
- Loading branch information
Showing
6 changed files
with
22 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
asyncpg==0.30.0 | ||
hikari==2.0.0.dev122 | ||
hikari-arc==1.1.0 | ||
ruff==0.2.0 | ||
pre-commit==3.6.0 | ||
python-dotenv==1.0.1 | ||
asyncpg==0.30.0 | ||
sqlalchemy==2.0.36 | ||
sqlalchemy==2.0.37 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
from sqlalchemy import Column, Integer, String | ||
from sqlalchemy.ext.asyncio import create_async_engine | ||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.orm import sessionmaker | ||
import logging | ||
|
||
from src.config import DB_HOST, DB_NAME, DB_USER, DB_PASSWORD | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
engine = create_async_engine(f"postgresql+asyncpg://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:5432/{DB_NAME}", echo=False) | ||
engine = create_async_engine(f"postgresql+asyncpg://{DB_USER}:{DB_PASSWORD}@{DB_HOST}/{DB_NAME}", echo=False) | ||
|
||
|
||
Base = declarative_base() | ||
Session = sessionmaker(bind=engine) | ||
Session = async_sessionmaker(bind=engine) | ||
|
||
|
||
# Issue with db on startup recommended drop all tables | ||
def init_db(): | ||
Base.metadata.create_all(engine) | ||
async def init_db(): | ||
async with engine.begin() as conn: | ||
await conn.run_sync(Base.metadata.create_all) |