On Mon, 2009-09-07 at 05:25 -0700, Pythoni wrote:
> I would like to use the output of mysql command in my templates,
> e.g. Mysql command
> show databases
> will show all databases
> e.g.
> DB1, and DB2
> and  I would like to add these
> to
> 
> <select size="1" name="MyDBlist" >
>     <option selected="selected" value="">---------</option>
>     <option value="DB1">DB1</option>
>     <option value="DB2">DB2</option>
>   </select>
> 
> Is that possible?
> Thanks for help
> L.

http://docs.djangoproject.com/en/dev/topics/db/sql/#topics-db-sql

(It's linked as 'Raw SQL' from the documentation root, clearly hard to
find).

from django.db import connection
c = connection.cursor()
c.execute('SHOW DATABASES')
choices = c.fetchall()

Cheers

Tom


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

Reply via email to