2

I am trying to connect to a Microsoft SQL Server with the SQLite3 module.

Everything seems to be recognized, but for whatever reason it doesn't recognize my columns or tables.

import sqlite3
con = sqlite3.connect('V7.0.6_X2_857I.sql')
cur = con.cursor()
cur.execute("""SELECT * FROM TS857_5400""")
all = cur.fetchall()
print one

However, I am running into this error:

---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-39-04a8789e04a7> in <module>()
      3 con = sqlite3.connect('V7.0.6_X2_857I.sql')
      4 cur = con.cursor()
----> 5 cur.execute("""SELECT * FROM TS857_5400""")
      6 all = cur.fetchall()
      7 print one

OperationalError: no such table: TS857_5400

I know for a fact that this table exists, so I am wondering if this is some issue with the declared connection string or a limitation of SQLite3 (with SQL Server).

Thank you in advance.

0

2 Answers 2

5

SQLite is an entirely different database, see http://www.sqlite.org/; the sqlite3 module has nothing to do with Microsoft SQL Server, but everything with the embedded database instead.

In other words, you cannot connect to SQL Server using the sqlite3 module.

You'll need to install a 3rd-party library to connect. The Python Wiki lists several options, ranging from ODBC drivers to SQL Server dedicated connectors. Which one will work for you depends on your Python version and your current OS.

Sign up to request clarification or add additional context in comments.

Comments

2

You will find that SQLite has created a file called 'V7.0.6_X2_857I.sql' that contains a newly-created database. The sqlite3 module deals ONLY with SQLite and cannot connect to any other database type. You don't see the table because you are working in an empty database that you just created.

Unfortunately my driver knowledge isn't up to date, but what you need is a DB API-compliant driver module for SQL Server.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.