Nov-04-2021, 02:17 PM
Hi All,,
I'm a rookie with Python and as you can see from above I'm getting the following message. If I remove the xport line I receive no errors. Am I calling xport the wrong way?
Thanks
I'm a rookie with Python and as you can see from above I'm getting the following message. If I remove the xport line I receive no errors. Am I calling xport the wrong way?
Thanks
Error:"module' object is not callable"
import pandas as pd import pyodbc import xport # Trusted Connection to Named Instance try: connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=laptop\MS_SQLEXPRESS;DATABASE=CheckData;Trusted_Connection=yes;') except Exception as err: print('Exception occured while trying to create a connection ', err) else: try: sql_query = pd.read_sql_query('''EXEC sp_Rtest''', connection) # here, the 'connection' is the variable that contains your database connection information from step 2 df = pd.DataFrame(sql_query) pd.set_option("display.max_columns", None) df.head() with open("C:/Users/myfiles/my_file.xpt", "wb") as f:xport(df,f) except Exception as err: print('Exception occurred while fetching records ', err) else: print('') finally: print('') finally: connection.close()