Wednesday, January 23, 2013

how do I code sql using the raw method?

Hello,

I need to code a select statement based on a dynamic field.

select price_a as price from table

def return priceLevel(x):
if x == 'A': return 'price_a'
if x == 'B': return 'price_b'
if x == 'C': return 'price_c'

so my sql would be:

fld = priceLevel('B')
select fld as price from table

I cannot get the select statement to work.
Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/qdMONF2utQgJ.
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