I cannot connect to mySQl db using pyodbc.
Here is a snippet of my script:
import pyodbc
import csv
cnxn = pyodbc.connect("DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=mydb; UID=root; PASSWORD=thatwouldbetelling;")
crsr = cnxn.cursor()
with open('C:\\skunkworks\\archive\\data\\myfile.csv','r') as myfile:
rows = csv.reader(myfile, delimiter=',', quotechar='"')
for row in rows:
insert_str = 'INSERT into raw_data VALUES(something, something)'
print insert_str
cnxn.commit()
myfile.close()
I get this error in the pyodbc.connect () line:
pyodbc.Error: ('IM002', '[IM002] [Microsoft] [ODBC driver manager] Data source name was not found and the specified driver is not used by default (0) (SQLDriverConnectW)')
I have another question regarding this error (and Python scripts in general). When I run this as a script, it fails (I was expecting a stack trace). I have to enter each line manually to find where the error occurred.
Right now I'm a little lazy (without exception handling) - is this normal Python script behavior without exception handling to fail?
[change]
mysqldb, pyodbc (MS Access). , , pyodbc, // ( Python) "". Windows mySQl Linux. Linux, terra firma.
"script". .py, python myscript.py . XP