writing a custom backend handler

11 views
Skip to first unread message

Ian Holsman

unread,
Aug 8, 2008, 6:03:59 PM8/8/08
to django-d...@googlegroups.com
Hey guys.

I want to use django against a webservice like dbslayer -
http://code.nytimes.com/projects/dbslayer
(which is basically Mysql over http).

I have it basically working (firing off selects and getting the
results), but It seems like django is getting itself into a look and
calling 'fetchmany' over and over.

this is what i'm seeing:

In [2]: Url.objects.get(pk=5)
SELECT `url`.`id`, `url`.`domain_id`, `url`.`URL`, `url`.`title`,
`url`.`description`, `url`.`update_at` FROM `url` WHERE `url`.`id` =
BINARY %s ORDER BY `url`.`title` ASC

fetchmany 100
http://localhost:8080/jAtomics/select/?q=SELECT+%60url%60.%60id%60%2C+%60url%60.%60domain_id%60%2C+%60url%60.%60URL%60%2C+%60url%60.%60title%60%2C+%60url%60.%60description%60%2C+%60url%60.%60update_at%60+FROM+%60url%60+WHERE+%60url%60.%60id%60+%3D+BINARY+5++ORDER+BY+%60url%60.%60title%60+ASC&start=1&rows=100&version=1&format=json
[]
fetchmany 100
http://localhost:8080/jAtomics/select/?q=SELECT+%60url%60.%60id%60%2C+%60url%60.%60domain_id%60%2C+%60url%60.%60URL%60%2C+%60url%60.%60title%60%2C+%60url%60.%60description%60%2C+%60url%60.%60update_at%60+FROM+%60url%60+WHERE+%60url%60.%60id%60+%3D+BINARY+5++ORDER+BY+%60url%60.%60title%60+ASC&start=101&rows=100&version=1&format=json
[]


how do I get fetchmany from stop asking for more rows?

TIA
Ian


Malcolm Tredinnick

unread,
Aug 8, 2008, 6:12:30 PM8/8/08
to django-d...@googlegroups.com

On Sat, 2008-08-09 at 08:03 +1000, Ian Holsman wrote:
> Hey guys.
>
> I want to use django against a webservice like dbslayer -
> http://code.nytimes.com/projects/dbslayer
> (which is basically Mysql over http).
>
> I have it basically working (firing off selects and getting the
> results), but It seems like django is getting itself into a look and
> calling 'fetchmany' over and over.

I'm guessing you need to override
BaseDatabaseFeatures.empty_fetchmany_value to be the correct empty
sequence.

Regards,
Malcolm


Ian Holsman

unread,
Aug 8, 2008, 6:54:12 PM8/8/08
to django-d...@googlegroups.com
That was it!

Thanks Malcom.

Simon Willison

unread,
Aug 8, 2008, 7:13:27 PM8/8/08
to Django developers
On Aug 8, 11:03 pm, Ian Holsman <kry...@gmail.com> wrote:
> I want to use django against a webservice like dbslayer -http://code.nytimes.com/projects/dbslayer
> (which is basically Mysql over http).

Ooh, exciting. Since dbslayer uses HTTP rather than a database client
library it would work really well with eventlet / mulib - eventlet
uses continuations and non-blocking IO and can monkey-patch HTTP calls
to work in a non blocking fashion. Having a dbslayer backend for
Django would hence mean Django could be deployed directly on eventlet,
which should be able to handle interesting things like massive
concurrency and comet-style persistent connections.

Ian Holsman

unread,
Aug 8, 2008, 7:35:18 PM8/8/08
to django-d...@googlegroups.com

ok.. so when I get this going I'll put it up as a patch.

we use something called atomics
(http://conferences.oreillynet.com/cs/mysqluc2005/view/e_sess/7066 )
which was never opensourced... but it is pretty much the same as dbslayer.

I'll look at getting the java-version of it opensourced.

Reply all
Reply to author
Forward
0 new messages