I am using following code to connect to the SQL Server and return the connection in order to be able to use in other function. However, I am getting an error of can't pickle pyodbc.Connection objects
The code is:
def connect_to_the_DB(**kwargs):
#Connection to SQL Server
conn = pyodbc.connect(driver='{ODBC Driver 17 for SQL Server}',
server='test.co.uk',
database='testdb',
uid='crm',
pwd='test123')
print("Connection established")
logging.info("Connection established")
return conn
Any tips, how I can solve it?