connect_odbc fails

User 3802 | 6/15/2016, 3:11:23 PM

I am trying to use sqlite on my mac, I believe I set up the DSN correctly since when I type the command line isql mysqlitedb username password +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> CREATE TABLE numbers(a int, b int); SQLRowCount returns 0 SQL> insert into numbers values(1,3); SQLRowCount returns 1 SQL> insert into numbers values(3,5); SQLRowCount returns 1 SQL> select * from numbers; +-----------+-----------+ | a | b | +-----------+-----------+ | 1 | 3 | | 3 | 5 | +-----------+-----------+

However when I try to use the graphlab I can not connect. import graphlab conn = graphlab.connect_odbc('DSN=mysqlitedb ;UID=username;PWD=password') I get the following error RuntimeError: Runtime Exception. Failed to connect to ODBC driver. IM002:1:0:[unixODBC][Driver Manager]Data source name not found, and no default driver specified

I do not know if this is relevant but when I try to connect this way it works.

import sqlite3
dbc=sqlite3.connect("mysqlitedb")
cur=dbc.cursor()
cur.execute("create table foo (id int, name string)")
cur.execute("insert into foo values(1, 'Me')")
cur.execute("insert into foo values(2, 'You')")
dbc.commit()
cur.execute("select * from foo")
print cur.fetchall()

Since my objective is to use SFrames that is when I run into problems.

Comments

User 15 | 6/16/2016, 5:54:47 PM

Hmm. I don't know why that would be happening. The error message suggests there's something slightly off with either the connection string or the configuration. If this is the SQLite database, SQLite doesn't have a concept of a username or password, so maybe try to remove those from the connection string you are passing to connect_odbc. If that doesn't fix the problem, then post the config entry for your DSN and the output of odbcinst -j, and we can debug further.

I would expect the DBAPI2 code you posted to work. However, what that code is doing is likely creating a new database in a file called "mysqlitedb", and not using your ODBC DSN, as DBAPI2 is generally separate from ODBC. Just so you know though, we also have support for reading from DBAPI2 connection objects. Take a look at [fromsql](https://dato.com/products/create/docs/generated/graphlab.SFrame.fromsql.html). All you'll have to do is pass dbc from your code snippet to either from_sql or to_sql. It's generally easier than using ODBC.