My second data frame is not loading values when i create it. Any help with why it is not working? When i make my cursor a list, it has a bunch of values in it, but for whatever reason when i try to do a normal data frame load with pandas a second time, it does not work.
My code:
conn = pyodbc.connect(constr, autocommit=True) cursor = conn.cursor() secondCheckList = [] checkCount = 0 maxValue = 0 strsql = "SELECT * FROM CRMCSVFILE" cursor = cursor.execute(strsql) cols = [] SQLupdateNewIdField = "UPDATE CRMCSVFILE SET NEW_ID = ? WHERE Email_Address_Txt = ? OR TELEPHONE_NUM = ? OR DRIVER_LICENSE_NUM = ?" for row in cursor.description: cols.append(row[0]) df = pd.DataFrame.from_records(cursor) df.columns = cols newIdInt = 1 for row in range(len(df['Email_Address_Txt'])): #run initial search to figure out the max number of records. Look for email, phone, and drivers license, names have a chance not to be unique SQLrecordCheck = "SELECT * FROM CRMCSVFILE WHERE Email_Address_Txt = '" + str(df['Email_Address_Txt'][row]) + "' OR TELEPHONE_NUM = '" + str(df['Telephone_Num'][row]) + "' OR DRIVER_LICENSE_NUM = '" + str(df['Driver_License_Num'][row]) + "'" ## print(SQLrecordCheck) cursor = cursor.execute(SQLrecordCheck) ## maxValue is indeed a list filled with records maxValue =(list(cursor)) ## THIS IS WHERE PROBLEM OCCURS tempdf = pd.DataFrame.from_records(cursor)