class index:
def GET(self):
movies = db.select('movie')
return render.index(movies)
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
问题是我的网页总是报错:no such table:movie.
我确定自己已经建好表了,cmd相关情况如下:
D:\python>sqlite3
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .databases
main:
sqlite> create table movie(title,year,country,abstract);
sqlite> insert into movie
...> values ('阿甘正传', 1994, '美国', 'Life is like a box of chocolates.');
sqlite> insert into movie
...> values ('肖申克的救赎', 1994, '美国', 'Hope is a good thing.');
sqlite> select*from movie;
阿甘正传|1994|美国|Life is like a box of chocolates.
肖申克的救赎|1994|美国|Hope is a good thing.
sqlite> .tables
movie
sqlite> .quit
D:\python>python web1.py 127.0.0.1 http://127.0.0.1:8080/
ERR: SELECT * FROM movie
Traceback (most recent call last):
File "C:\Python3\lib\site-packages\web\application.py", line 257, in process
return self.handle()
File "C:\Python3\lib\site-packages\web\application.py", line 248, in handle
return self._delegate(fn, self.fvars, args)
File "C:\Python3\lib\site-packages\web\application.py", line 488, in _delegate
return handle_class(cls)
File "C:\Python3\lib\site-packages\web\application.py", line 466, in handle_class
return tocall(*args)
File "D:\python\web1.py", line 13, in GET
movies = db.select('movie')
File "C:\Python3\lib\site-packages\web\db.py", line 705, in select
return self.query(qout, processed=True)
File "C:\Python3\lib\site-packages\web\db.py", line 1058, in query
out = DB.query(self, *a, **kw)
File "C:\Python3\lib\site-packages\web\db.py", line 665, in query
self._db_execute(db_cursor, sql_query)
File "C:\Python3\lib\site-packages\web\db.py", line 596, in _db_execute
out = cur.execute(query, params)
sqlite3.OperationalError: no such table: movie
127.0.0.1:54375 - - [13/Feb/2018 23:59:13] "HTTP/1.1 GET /" - 500 Internal Server Error