Prepared Statements
Ben Lamb <[email protected]>
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
In my program I was building SQL queries in this fashion:
sql = "SELECT wibble FROM wobble "
sql += " WHERE somefield = '%s';" % some_variable
cursor.execute(sql)
Doing it properely gives me flexibility, especially with regard to quoting
bytea values, and security, viz:
cursor.execute("SELECT wibble FROM wobble WHERE somefield = %s;",
some_variable)
However, some of my SQL statements get rather complicated, is there a way of
building one up gradually then passing it to cursor.execute()? Sometimes I
need to include/exclude entire subclauses.
Thanks,
Ben Lamb.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf