Questions to DB-API 2
andrew-pythonlist at puzzling.org
Fri Feb 21 14:40:12 CET 2003
On Fri, Feb 21, 2003 at 06:45:46AM -0500, Jp Calderone wrote:
> On Fri, Feb 21, 2003 at 03:00:03AM -0800, Jakob Simon-Gaarde wrote:
> > Quiestions to DB-API 2
> > 1. In DB-API 1 using the odbc module I was able to use question-signs
> > to format my SQL, thus things like pings around strings and date
> > formats was automatically taken care of. I would write something like
> > this:
> > cur.execute("insert into table (text,number,date) values (?,?,?)",
> > (strvar,numvar,datevar))
> > Unfortunately this doesen't seem to work in DB-API 2 but since I don't
> > expect that it is a degrade compared to DB-API 1 I guess there must be
> > some other way.
> > Can anybody help please. Is there a tutorial to db-api 2 with usage
> > examples, because the description on python.org/topics/db isn't very
> > informative in the respects of usage.
> Sadly, DB-API 2 leaves this particular aspect unspecified, and so
> implementations vary. If "?" doesn't work, "%s" tends to. The
> documentation to the particular module you're using almost certainly
> describe which format is supported.
You should be able to check this at runtime, by looking at the 'paramstyle'
attribute of your DB-API 2 module. See the DB-API spec for possible values.
It'd be much simpler if they all just used the one standard format.
More information about the Python-list