Wednesday, April 20, 2011

Re: how to call user-defined database functions through the Django query syntax?

Hi Andrew,

On Wed, Apr 20, 2011 at 5:18 PM, Andrew Dalke <andrewdalke@gmail.com> wrote:
> I'm using MySQL and sometimes SQLite as the backend database. Both
> databases let me add user-defined functions. I've made a set of UDFs
> specific to my problem domain, which is chemsitry.
>
> How do I call them from a database query?

I recently put some spare time on the same problem, trying to extend
the django database API to support the management of chemical
information. My approach to the problem consisted in taking geodjango
as a reference extension targeting a specific application domain, I
removed the gis-specific features and I then adapted the main skeleton
to expose some basic functionalities. This way I was able to map
structure searches to calls like

Compound.objects.filter(structure__contains='c1cccnc1')

or

Compound.objects.filter(structure__matches='c1cccac1')

I think the result is still very sketchy and experimental, and it
might benefit a review by someone with some real understanding of the
ORM internals (I only learned some through the process), but if you
were interested you can find it here:
https://github.com/rvianello/django-chem. Depending on your plans, it
would be interesting if we could collaborate on this.

Riccardo

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate