Problem with sqlite

Tim Roberts timr at probo.com
Sat Mar 29 21:10:11 EDT 2008


aiwarrior <zubeido at yahoo.com.br> wrote:
>
>I'm sorry about not saying showing the libraries. It was not on
>purpose.

You didn't make any comment on the rest of Gerhard's suggestion, nor does
it appear that you took any action to correct them.

You should get out of the habit of using extra parentheses in "if" and
"print" statements.  They are not needed in Python, and they make the code
more difficult to read.

>            self.cursor.execute( "CREATE TABLE database
>(album,filepath)" )

Note the order of the fields: album, then path.

>    def add_entry( self, eone , etwo ): #Add entry to database
>        self.cursor.execute( "INSERT INTO database (album,filepath)
>VALUES (?,?)", ( eone , etwo ) )
>        return 1 #TODO: exception handler

Again note the order of the fields here: album, then path.

>    def get_value( self, column ):
>        self.cursor.execute( "SELECT %s FROM database" % column )
>        for n in self.cursor:
>             print n

I suspect you wanted "self.cursor.fetchall()" there, but since you don't
call it, it doesn't matter yet.

>                    db.add_entry( joined, audio['album'] )

Now note the order that you supply the fields: path first, album second.
You are inserting the fields in the wrong order here.

>This is all the code. Some of that try pass code is just something i
>glued to create a clean slate database file

And such gluing is a very bad idea, because it is apparently hiding the
real cause of your problems.  Get rid of the try/except/pass sequences
until you understand what is failing.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list