On Thu, 7 Feb 2008 12:51:56 -0800 (PST) Michael Castleton <[EMAIL PROTECTED]> wrote:
> > Hello, > I think I am missing something very simple. The following command works fine > if there is no variable substitution: > cur2.execute("SELECT date,lat1,lon1 FROM table WHERE eventid = 1001;") > > 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? In generally, not reading http://catb.org/~esr/faqs/smart-questions.html (or maybe not recently). In particular, you're not telling us which version of python you're using, which database (and version) you're using, and which interface module you're using. The correct way to write your query depends on those. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig