Skip to content

Commit

Permalink
chore: Refactor get_engine function to use get_connection instead
Browse files Browse the repository at this point in the history
  • Loading branch information
fcoagz committed Jul 22, 2024
1 parent ea8a386 commit a32ce92
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pyDolarVenezuela/data/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
from ..models import Database, LocalDatabase

# https://github.com/orgs/supabase/discussions/27071 Using SQLAlchemy with Supabase
def get_engine(connection: Union[Database, LocalDatabase]):
def get_connection(connection: Union[Database, LocalDatabase]):
"""
Obtiene un motor de base de datos (engine) de SQLAlchemy según el tipo de conexión proporcionada.
"""
if isinstance(connection, Database):
return create_engine(f'{connection.motor}://{connection.user}:{connection.password}@{connection.host}:{connection.port}/{connection.database}')
elif isinstance(connection, LocalDatabase):
return create_engine(f'{connection.motor}:///{connection.url}')
else:
raise ValueError("The connection must be a Database or LocalDatabase object")

def get_connection(connection: Union[Database, LocalDatabase]):
engine = get_engine(connection)
return engine

def create_tables(engine):
"""
Expand Down

0 comments on commit a32ce92

Please sign in to comment.