Gilles Ganault a écrit :
On Thu, 23 Oct 2008 00:24:01 -0200, "Gabriel Genellina"
<[EMAIL PROTECTED]> wrote:
In case you didn't notice, B.D. already provided the answer you're after -
reread his 3rd paragraph from the end.
Yes, but it doesn't work with this wrapper (APSW version 3.5.9-r1):
The recommended way is to pass the arguments to cursor.execute, ie:
I'm getting an error when doing it this way:
=======
isbn = "123"
sql = "SELECT COUNT(*) FROM books WHERE isbn='%s'"
#Incorrect number of bindings supplied. The current statement uses 0
and there are 1 supplied. Current offset is 0
cursor.execute(sql, (isbn,))
There was a notice about checking the correct placeholder for your
db-api implementation - it's not necessarily '%s' !-)
=======
I don't know enough about Python and this wrapper to tell why it
triggers an error.
you want:
row = cursor.fetchone()
count = row[0]
if not count:
This wrapper doesn't seem to support fetchone():
=====
#AttributeError: 'apsw.Cursor' object has no attribute 'fetchone'
row = cursor.fetchone()
=====
This works, though:
========
cursor.execute(sql)
for row in cursor.execute(sql):
#Record not found -> Insert
if not row[0]:
Ok, so I wrongly assumed this apws stuff was db-api compliant, and you
can as well forget everything I wrote. My fault, I should have
double-checked this before answering.
--
http://mail.python.org/mailman/listinfo/python-list