Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'parameters': 0.04; 'none:': 0.07; 'subject:query': 0.07; 'advance': 0.07; 'function,': 0.09; 'none):': 0.09; 'parameter': 0.09; 'part,': 0.09; 'subject:()': 0.09; 'python': 0.11; 'def': 0.12; '2.7': 0.14; "%s'": 0.16; "(it's": 0.16; "?',": 0.16; 'hidden,': 0.16; 'received:217.194': 0.16; 'subject:parameters': 0.16; 'substitution': 0.16; 'all.': 0.16; 'charset:iso-8859-15': 0.16; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'format,': 0.24; 'received:192.168.1.100': 0.24; 'query': 0.26; 'pass': 0.26; 'function': 0.29; "i'm": 0.30; 'piece': 0.31; 'another': 0.32; 'something': 0.35; 'but': 0.35; 'thanks': 0.36; 'possible': 0.36; 'received:it': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'received:217': 0.63; 'real': 0.63; 'id,': 0.84; 'subject:Using': 0.84; 'catalog': 0.93 Date: Fri, 28 Mar 2014 09:44:43 +0100 From: Daniele Forghieri User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Using query parameters subtitution outside of execute() Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395996885 news.xs4all.nl 2973 [2001:888:2000:d::a6]:34328 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69258 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