Skip to content

Commit

Permalink
port sqlalchemy config
Browse files Browse the repository at this point in the history
  • Loading branch information
maximemuldermcgill committed Aug 26, 2024
1 parent 9d4388a commit 74e7698
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions python/lib/db/connect.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from typing import Any

Check failure on line 1 in python/lib/db/connect.py

View workflow job for this annotation

GitHub Actions / flake8-lint

[flake8] reported by reviewdog 🐶 'typing.Any' imported but unused Raw Output: ./python/lib/db/connect.py:1:1: F401 'typing.Any' imported but unused
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from lib.dataclass.config import DatabaseConfig


default_port = 3306


def connect_to_db(credentials: dict[str, Any]):
host = credentials['host']
port = credentials['port']
username = credentials['username']
password = credentials['passwd']
database = credentials['database']
port = int(port) if port else default_port
def connect_to_db(credentials: DatabaseConfig):
host = credentials.host
port = credentials.port
username = credentials.username
password = credentials.password
database = credentials.database
engine = create_engine(f'mariadb+mysqlconnector://{username}:{password}@{host}:{port}/{database}')
return Session(engine)

0 comments on commit 74e7698

Please sign in to comment.