MySql -Python question

Vladimir 'Yu' Stepanov vys at renet.ru
Mon Apr 24 06:38:47 EDT 2006


Dennis Lee Bieber wrote:
> On 23 Apr 2006 21:25:48 -0700, ataanis at gmail.com declaimed the following
> in comp.lang.python:
>
>   
>> Hey all, I'm running a query within some python code, and I'm having
>> difficulties doing something that seems to be really simple . I'm
>> running a query in the following form:
>> query01 = 'select max(DirectorID) +1 from Director;'
>>         cursor.execute(query01)
>>         table = cursor.fetchall()
>> the resulting table , is a 1 row , 1 column table,showing 1 number and
>> I just need that number inside that table,and save it for a different
>> query,  but I can't get it , can anybody tell me the best way to do
>> this? thanks
>>     
>
> 	What does
>
> 		table[0]		#first element of list "table"
>
> return to you? Or, since fetchall() might be assuming multiple rows even
> for a single row data set...
>
> 		table[0][0]	#first element of first sublist of list "table"
>   

There is no method for work with data who are presented only in one 
column. This method would raise speed of work with such data as it is 
not necessary to make allocation one-item tuple object.

Therefore I have a some expanded the module py-sqlplug_mysql
(http://sourceforge.net/projects/py-sqlplg-mysql) where such API it is
delivered through methods of the cursor: fetchcol0, fetchallcol0,
fetchmanycol0.

Now on a site of the project the documentation is inaccessible. The
basic methods correspond to the specification described in PEP-249.

P.S. The project while was tested only on FreeBSD and Linux though can
work and on other platforms.

P.P.S. For drawing up of the documentation the translator from Russian
is required.



More information about the Python-list mailing list