[APSW] SELECT COUNT(*) not succesfull?

Gilles Ganault nospam at nospam.com
Thu Oct 23 09:26:54 CEST 2008

On Thu, 23 Oct 2008 00:24:01 -0200, "Gabriel Genellina"
<gagsl-py2 at yahoo.com.ar> 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,))

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:
	for row in cursor.execute(sql):
		#Record not found -> Insert
		if not row[0]:


Thank you.

More information about the Python-list mailing list