Category : pyodbc

I’m using pyodbc to query from MYSQL table… Here is the code I’m using def getData(tableName): try: cnxn = pyodbc.connect(con_string) cursor = cnxn.cursor() cursor.execute("SELECT * from " + database + tableName) rows = cursor.fetchall() if len(rows) == 0: resp = {‘status’: 501, ‘message’: ‘No data from database’} raise Exception(resp) cnxn.close() appLogger.info("Insert Batch detail in Doc_Batch ..

Read more

I’m trying to load a couple of .csv file to SQL Server database with Python and Pandas. when i run my code i get this error: (‘42000’, "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]The identifier that starts with ‘ticker,stkPx,expirDate,yte,strike,cVolu,cOi,pVolu,pOi,cBidPx,cValue,cAskPx,pBidPx,pValue,pAskPx,cBidIv,cMidIv,cAskIv,smoothSmvVo’ is too long. Maximum length is 128. (103) (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not ..

Read more

I’m trying to load a couple of .csv file to SQL Database. im doing this with python. when i run my code i get this error: Parameter 39 (”“): The supplied value is not a valid instance of data type float.” i dont have 39 parameters… would appreciate all the help i can get! import ..

Read more

following Query contains the Error "Data type mismatch in criteria expression": cursor.execute("SELECT DISTINCT Field1 FROM Table WHERE IdField = ‘X’ AND Field2 <> Field3") if i change the Code to cursor.execute("SELECT Field3 FROM Table WHERE IdField = ‘X’") f3 = cursor.fetchone() cursor.execute("SELECT DISTINCT Field1 FROM Table WHERE IdField = ‘X’ AND Field2 <> "+f3[0]+"") it ..

Read more