Michael Castleton schrieb: > but when I try the following I get 'TypeError: unindexable object': > > events = [1001,1002,1003] > for num in events: > cur2.execute("SELECT date,lat1,lon1 FROM table WHERE eventid = %s",(num,)) > > I have tried all manor of variation I can think of - (%s,)(num,) or '%s', > num or %(what)s,{what:(num,)} etc.. > > Any ideas on what I'm doing wrong?
psycopg2 uses paramstyle = pyformat, so %(what)s would be the right syntax. Also, since you are calling execute (not executemany), you must not use a sequence as parameters, but only one dict, like that: cur2.execute("SELECT ... WHERE eventid = %(num)s", dict(num=num)) -- Christoph _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig