Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69258 > unrolled thread

Using query parameters subtitution outside of execute()

Started byDaniele Forghieri <guru@digitalfantasy.it>
First post2014-03-28 09:44 +0100
Last post2014-03-28 09:44 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Using query parameters subtitution outside of execute() Daniele Forghieri <guru@digitalfantasy.it> - 2014-03-28 09:44 +0100

#69258 — Using query parameters subtitution outside of execute()

FromDaniele Forghieri <guru@digitalfantasy.it>
Date2014-03-28 09:44 +0100
SubjectUsing query parameters subtitution outside of execute()
Message-ID<mailman.8662.1395996885.18130.python-list@python.org>
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



[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web