mercredi 25 novembre 2015

Python to SQLite3

I am making a project where I connect to a database with Python then update and change things. I have run into problems when trying to retrieve information.

I am using this code:

import sqlite3
conn = sqlite3.connect('Project.db')

print ("Opened database sucessfully")

cursor = conn.execute("SELECT ID,ResidentTitle,ResidentForname FROM Residents")
for row in cursor:
    print ("ID = "), row[0]
    print ("ResidentTitle ="), row[1]
    print ("Name ="), row[2]

print ("done");
conn.close()

from this I am getting back the error:

Traceback (most recent call last):
File "C:/sqlite/Sqlplz.py", line 7, in <module>
cursor = conn.execute("SELECT ID,ResidentTitle,ResidentForname FROM Residents")
sqlite3.OperationalError: no such table: Residents

How can I resolve this error?

Aucun commentaire:

Enregistrer un commentaire