problem with sqlite3: cannot use < in a SQL query with (?)

bob gailer bgailer at gmail.com
Wed Jan 22 21:51:56 EST 2014


On 1/22/2014 9:32 PM, lgabiot wrote:
> Hello,
>
> I'm building an application using a simple sqlite3 database.
> At some point, I need to select rows (more precisely some fields in 
> rows) that have the following property: their field max_level (an INT),
> should not exceed a value stored in a variable called threshold, where 
> an int is stored (value 20000).
> (threshold needs to be set by the user, so I cannot hard code a value 
> there).
>
> My database already exist on my drive (and of course the sqlite3 
> module is imported)
>
> I do the following:
>
> >>>conn = sqlite3.connect(mydb) # open the database
> that's OK
>
> >>>cursor = conn.execute("SELECT filename, filepath  FROM files WHERE 
> max_level<(?)", threshold)
> that doesn't work (throw an exception)
>
> if I do:
> >>>cursor = conn.execute("SELECT filename, filepath  FROM files WHERE 
> max_level<20000)")
> it works...
>
> I did similar operations on UPDATE instead of SELECT, and it works there.
SO SHOW US THE UPDATE. "Similar" does not help.
> Maybe my mind is fried right now, but I can't figure out the solution...
>
> best regards.




More information about the Python-list mailing list