I have a curious problem with Python 2.5's SQL support. OK, so we import sqlite3 and create a connection object to an existing sql file. It happens. Then we call the connection's cursor method. OK.
Now, if you look up the sqlite documentation, the most important command is cursor.execute(), where your SQL command goes in the brackets as a triple-quoted multiline statement. Having done your SELECT FROM or whatever, you get back a result set object which you can either fetch bits from with the cursor's fetch() method or iterate through in a loop of some kind.
But I can't find any documentation for the case when you get back an AttributeError saying that the method cursor doesn't have an attribute called 'execute'. WTF? Can anyone explain this?
Bonus Pathetic: Offtopic, I was recently looking something up on the mod_python documentation site when I noticed a GoogleAd eyeing me - "Hacking All Day Won't Get You A Girlfriend! Don't Let Time Pass -" and then the URL of a dating agency. Made me laugh, at least.
Update: Woo. Incredibly pathetic error...
2 comments:
cursor isn't a method, it's a variable. Have you checked what class it is; according to the documentation it should be of class Cursor.
Yes, I realise that. Now all I need to do is convert a MySQL db into a sqlite3 one..
Post a Comment