Why Am I Suddenly Getting "operationalerror: No Such Table"?
Solution 1:
did you moved your code to another place?
because sqlite store the database into a file, when you call connect, if a file with the name 'mydatabase'
exist, it will be loaded, otherwise. a new fresh database file will be created automatically.
search for your old file with name 'mydatabase'
and put it within your code.
Solution 2:
I had exactly the same problem with sqlite3 and flask accessing a database. I changed the path to the database in my code to its full path and this solved the problem of data disappearing and tables not being found after restarting my flask application. I can recommend SQLite Manager firefox plugin, which helps with viewing records in your database tables. Follow this link to see a similar problem solved using full path references to your database Django beginner problem: manage.py dbsync
Python does not do path expansion.so you might want to use Environment variables to store paths to your database. Link to WingWare's Environment Variable expansion
Solution 3:
I had the the problem. In my case, before trying to access the database I have this line:
os.chdir("other/dir")
conn = sqlite3.connect("database.db")
So sqlite3 create an empty database in that dir instead.
Solution 4:
I had the same problem, in my case i was creating trying to create Tables before tables before creating tables, here is an example
Base.metadata.create_all(bind=engine) # Wrong placement
class Currency(Base):
__tablename__ = "currency"
date=Column(Date, primary_key =True)
rates =Column(String)
I fixed it with replacing the position of Base Creator
class Currency(Base):
__tablename__ = "currency"
date=Column(Date, primary_key =True)
rates =Column(String)
Base.metadata.create_all(bind=engine) # Right placement
Post a Comment for "Why Am I Suddenly Getting "operationalerror: No Such Table"?"