From 0329e3546cc7c9f36897c42d448c4b874d1613cb Mon Sep 17 00:00:00 2001 From: yuvaneshkm Date: Mon, 17 Jun 2024 02:24:34 +0530 Subject: [PATCH] 'final_update' --- src/dbsconnector/databases.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dbsconnector/databases.py b/src/dbsconnector/databases.py index 697b0ce..b8ac045 100644 --- a/src/dbsconnector/databases.py +++ b/src/dbsconnector/databases.py @@ -1,8 +1,9 @@ # importing necessary libraries import pandas as pd from pathlib import Path -from pymysql import connect +import pymysql from pymongo.mongo_client import MongoClient +from typing import Optional # load csv file: @@ -24,9 +25,11 @@ def load_gsheet(gsheet_id:str, sheet_name:str): # load mysql data: def load_mysqldata(host:str, user:str, password:str, database:str, table:str): - db = connect(host=host, user=user, passwd=password, database=database) + db: Optional[pymysql.Connection] = None + db = pymysql.connect(host=host, user=user, passwd=password, database=database) cur = db.cursor() query = f'select * from {table}' + cur.close() return pd.read_sql(query, db) # load mongodb data: