[Twisted-Python] Case for an Async MySQL Driver?

orbitz orbitz at ezabel.com
Thu Oct 28 17:00:57 EDT 2004

Hrm, wouldn't it be a bit nicer on programmers to use the current adbapi 
interface so they can just move all their code to this new mysql API?

Seun Osewa wrote:

>Nick Arnett wrote:
>>Anybody want to offer more about how this might look? I don't know if I
>>can fit it into my work, but it would be a terrific addition to my
>>toolbox (I have many thousands of lines of Python talking to MySQL).
>>And I suppose it would offer the excuse I've been needing to ask our CEO
>>about his thoughts on open-sourcing parts of our code.
>Here are some ideas for an async MySQL 'driver' for Twisted:
>1) create or use a connection:
>connection = MySqlPool.connect("hostname", "username", "password")
>2) send a query:
>d = connection.exec(["begin", "update db.stats set value=value+1 where
>accesses", "select * from db.important_table", "commit"])
>def myCallBack (resultset):
>    # 'results' contains the result of the last QUERY in the list of
>commands sent to exec.
>    # it is empty if there's no QUERY and no error
>     ....
>def myErrBack (errorval, errorstring command_id):
>   # this is called if there's an error in executing any of the commands
>   # command_id indicates which point in the list of commands the error occured
>   # errorval is the error name/number, errorstring the exact result
>3) close the connection:
>This format allows the user to send an unlimited number of queries to
>be run together, thus limiting the number of callbacks necessary for a
>program requiring many small interactions with the database. "begin"
>and "end" will count as an example.  This minimalistic API also allows
>more advanced (twisted.enterprise style) interfaces to be built on top
>of it.
>Is there any task you can think of that can't be built on top of this?
>(of course I've not touched the implementation details...)
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com

More information about the Twisted-Python mailing list