[Tutor] flask/sqlite3 problem - 'OperationalError: no such table'?

Timo timomlists at gmail.com
Wed Sep 18 19:13:10 CEST 2013


Op 18-09-13 15:37, Alan Gauld schreef:
> On 18/09/13 09:10, memilanuk wrote:
>
>
>> def main():
>>      g.db = connect_db()
>>      cur = g.db.execute('SELECT * FROM posts')
>
> You are trying to execute on the database rather
> than on a cursor. You need to create a cursor
> first to hold your results.
>
> Something like;
>
> cur = g.db.cursor()
> cur.execute(.....)
Not really.

sqlite3.connect() returns a sqlite3.Connection object which has a 
execute method. It will create a cursor object for you.

Cheers,
Timo

>
> HTH



More information about the Tutor mailing list