Wednesday, August 25, 2010

Converting a query using extra from Postgres to Mysql

Hi to all django users,

i just completed a project in which I used the extra() database API
function in order to save the number of query used. Unfortunately the
production server doesn't use Postgres but MySQL.

I don't know why but I'm not making it to convert the query so it's
compatible with MySQL, is there any good mate that can help me on
this?

This is the code:

locations = Location.objects.filter(category=category.id,
status=2).extra(
select={
'image': 'SELECT "locations_images"."image" FROM
"locations_images" '
'WHERE ('
'"locations_images"."location_id" =
"locations_location"."id"::integer '
')'
' ORDER BY "locations_images"."order" ASC LIMIT 1'
},
).only('name', 'slug')

--
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