Yeah the DAL didn't work as planed. Your final suggestion worked. I was using postgresql. With sqlalchemy you can use :keyword I guess web2py requires %%(keyword)s as you said above.
Thanks for the help, this one was driving me crazy :D On Fri, Feb 10, 2012 at 12:16 PM, Niphlod <niph...@gmail.com> wrote: > PS: for postgresql, it's nasty ... placeholders are in "python" notation, > so > > db.executesql('select * from %s', placeholders=('example')) > > or > > db.executesql('select * from %(tablename)s', placeholders={'tablename' : > 'example'}) > > works. > > If payback types is passed as a string, you need to add a % to retain the > quoted template, I guess > > > payback_types = ('s','p') > query_string = """ > select sum(happen_amount) from cash_journal > where distributor_id = 1 > and transaction_type in %(types)s > and extract(epoch from (%%s - happen_time)) < %%s;""" % { > 'types': str(payback_types) > } > > lockAmount = self.db.executesql(query_**string, > placeholders=(now, seconds)) > or > > > payback_types = ('s','p') > query_string = """ > select sum(happen_amount) from cash_journal > where distributor_id = 1 > and transaction_type in %(types)s > and extract(epoch from (%%(now)s - happen_time)) < > %%(seconds)s;""" % { > 'types': str(payback_types) > } > > lockAmount = self.db.executesql(query_**string, > placeholders=dict(now=now, seconds=seconds)) > > should work as intended. > > > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com