Skip to content

Commit

Permalink
Fix common/tools.py
Browse files Browse the repository at this point in the history
Fixed `export_to_sql` function in common/tools.py
  • Loading branch information
rahul4732saini committed Jul 29, 2024
1 parent 2cf830b commit 0945a05
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fise/common/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
import pandas as pd
from sqlalchemy.exc import OperationalError
from sqlalchemy import Engine, URL
from sqlalchemy.engine import Engine, URL, Connection
import sqlalchemy

from . import constants
Expand Down Expand Up @@ -199,16 +199,16 @@ def export_to_sql(data: pd.DataFrame, database: str) -> None:
"""

# Creates an `sqlalchemy.Engine` object of the specified SQL database.
conn: Engine = (
engine: Engine = (
_connect_sqlite() if database == "sqlite" else _connect_database(database)
)

table: str = input("Table name: ")
metadata = sqlalchemy.MetaData()

try:
metadata.reflect(bind=conn)
conn.connect()
metadata.reflect(bind=engine)
conn: Connection = engine.connect()

except OperationalError:
raise OperationError(f"Unable to connect to {database!r} database.")
Expand Down

0 comments on commit 0945a05

Please sign in to comment.