Connect to Database on local host with sqlite3 in python
<p>I have a database that I am running on my local machine which I can access through Microsoft SQL Server Manager Studio. I connect to this server "JIMS-LAPTOP\SQLEXPRESS" and then I can run queries through the manager. However I need to be able to connect to this database and work with it through python. 
When I try to connect using sqlite3 like </p>

<pre><code>conn = sqlite3.connect("JIMS-LAPTOP\SQLEXPRESS")
</code></pre>

<p>I get an unable to open database file error</p>

<p>I tried accessing the temporary file directly like this</p>

<pre><code>conn = sqlite3.connect("C:\Users\Jim Notaro\AppData\Local\Temp\~vs13A7.sql")
c = conn.cursor()
c.execute("SELECT name FROM sqlite_master WHERE type = \"table\"")
print c.fetchall()
</code></pre>

<p>Which allows me to access a database but it is completely empty (No tables are displayed)</p>

<p>I also tried connecting like this</p>

<pre><code>conn = sqlite3.connect("SQL SERVER (SQLEXPRESS)")
</code></pre>

<p>Which is what the name is in the sql server configuration manager but that also returns a blank database.</p>

<p>I'm not sure how I am suppose to be connecting to the database using python</p>

<p>You can't use sqlite3 to connect to SQL server, only to Sqlite databases.
You need to use a driver that can talk to MS SQL, like <code>pyodbc</code>.</p>

python sql sql-server database sqlite3