Note that there are some explanatory texts on larger screens.

plurals
  1. POpyodbc and mySQL
    primarykey
    data
    text
    <p>I am unable to connect to mySQl db using pyodbc.</p> <p>Here is a snippet of my script:</p> <pre><code>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 #crsr.execute(insert_str) cnxn.commit() myfile.close() </code></pre> <p>I get this error at the pyodbc.connect() line:</p> <blockquote> <p>pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')</p> </blockquote> <p>I have another question regarding this error (and Python scripts in general). When I run this as a script, it fails silently (I was expecting a stack trace). I have to type each line in manually to find where the error occured.</p> <p>I am being a bit lazy for now (no exception handling) - is this normal behaviour of a Python script without exception handling to fail silently?</p> <p><strong>[Edit]</strong></p> <p>I am not using mysqldb because I am already using pyodbc to extract my data from another source (MS Access). Ok, not a good reason - but I am already grappling with pyodbc and I dont really fancy having to wrestle with another library/module/package(whatever its called in Python) for a "one off" job. I just want to move my data of from various data sources in the Windows environment to mySQl on Linux. once on Linux, I'll be back on terra firma.</p> <p>That is the entire 'script' right there. I just saved the code above into a file with a .py extension, and I run python myscript.py at the command line. I am running this on my XP machine</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload