Using query parameters subtitution outside of execute()

D

Daniele Forghieri

Hi to all. I'm using sqlite3 with python 2.7 on windows.

I use the query substitution parameters in my query but I need to pass
part of the query to a function, something like (it's not the real
examples, just to clarify the question):

def loadAll(cursor, id, queryAdd = None):
if queryAdd is None:
qry = 'select * from files where catalog = ?'
else:
qry = 'select * from files where catalog = ? and %s' % (queryAdd))

cursor.execute(qry, (id, ))
...

I would like to use the query substitution even when I create, in
another piece of code, the queryAdd part, something like:

queryAdd = cursor.querySubst('enabled = ? and hide = ? and data > ?',
(enabled, hidden, min_date, ))

when the function take care of the date format, quoting the parameter
and so on

It's possible or not ?

Thanks in advance

Daniele Forghieri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top