Hi, I have posted a question about getting this to work with DAL, I am unable to do so. Therefor wish to just use executesql but am also having some issues.
The way we have been doing it with sqlalchemy: sqlstr = """ select sum(happen_amount) from cash_journal where transaction_type in ('s','l') and extract(epoch from (:now-happen_time))<:seconds and distributor_id = :id """ lockAmount = engine.execute(text(sqlstr), now=now, seconds=seconds, id=self.id).scalar() With executesql I have tried several things, now I am at this point: 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 - happen_time)) < :seconds;""" % { 'types': str(payback_types) } lockAmount = self.db.executesql(query_string, placeholders=dict(now=now, seconds=seconds)) Any suggestions? I have more then one piece of code that is going to require executesql. Traceback (most recent call last): File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py", line 204, in restricted exec ccode in environment File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/members.py" <http://127.0.0.1:8000/admin/edit/welcome/controllers/members.py>, line 806, in <module> File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py", line 172, in <lambda> self._caller = lambda f: f() File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/members.py" <http://127.0.0.1:8000/admin/edit/welcome/controllers/members.py>, line 6, in test_calculations print distributor_engine.get_cash_inlock_amount(distributor) File "applications/welcome/modules/distributor_api.py", line 127, in get_cash_inlock_amount lockAmount = self.db.executesql(query_string, placeholders=dict(now=now, seconds=seconds)) File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py", line 5169, in executesql self._adapter.execute(query, placeholders) File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py", line 1359, in execute return self.log_execute(*a, **b) File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py", line 1353, in log_execute ret = self.cursor.execute(*a, **b) OperationalError: near "from": syntax error -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com