[Stackless] Connecting To A Database

Matt Provost mprovost at termcap.net
Fri Jun 8 04:51:36 CEST 2007

On Fri, Jun 08, 2007 at 01:28:28AM +0100, Seun Osewa wrote:
> Hello Guys,
> I'm in love with the way Stackless combines the simplicity of
> procedural programming and the performance and memory efficiency of
> asynchronous web programming.  I also enjoy the determinism of
> cooperative micro-threading.
> I'm about to start writing my own scripts for new webapps and I'd like
> to standardize on Stackless Python.  I was able to create a minimal
> SCGI server for Stackless Python using the stacklesssocket module.
> But there's one big hurdle left to be crossed:
> Databases!  I need a database solution that will not cause me to lose
> the performance benefits of using stackless python.  None seems to
> exist for Stackless.  I'm sure there are others who are waiting for
> this same solution.
> What can we do to get MySQL/PostgreSQL/Sqlite3 database support on
> Stackless python?

It's been on my list of things to check out but I think the pg8000
postgres driver is a good candidate. (http://pybrary.net/pg8000/)

It's written in pure python so you can get at how it handles sockets.
The problem with most of the other drivers is that they are just
interfaces to the C libraries which then do their own socket handling so
you can't control it once you call into the C code.

I ran some tests with the pg8000 driver using stacklesssocket and it
works but it's much slower than using the regular socket code. But it
seems like it wouldn't be that bad to actually get into it and put some
stackless code directly into the driver instead of trying to trick it
via stacklesssocket. So you could for example watch a socket and send
results of a query back over a channel, etc.


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list