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?
2 Answers 2
cursor = conn.execute("SELECT ID,ResidentTitle,ResidentForname FROMResidents")
-------------------------------------------------------------------^
You are missing space, you should update like that
cursor = conn.execute("SELECT ID,ResidentTitle,ResidentForname FROM Residents")
answered Nov 25, 2015 at 16:29
Adem Öztaş
21.6k5 gold badges36 silver badges42 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Alexander
i uploaded the wrong code, i updated the problem, sorry.
Adem Öztaş
@Alexander, did you create Residents table?
Problem is fixed, issue with a broken save file.
Comments
default
FROMResidentsmust beFROM ResidentsResidentsin the database.