How can I execute raw SQL after connect to database? I need to run script once, after connect to DB. Thanks.
UPD: question is not how to run raw SQL.
How can I execute raw SQL after connect to database? I need to run script once, after connect to DB. Thanks.
UPD: question is not how to run raw SQL.
Just visit the docs here.
It was I think the second match on google with "Django ORM".
EDIT See comments
If you look at this Django page you see that MySQLdb (the underlying layer) also accepts an init_command option which is run immediately after a connection is established. That's a feature of MySQLdb, and not so much of Django itself.
If you are using django >= 1.2:
from django.db import connection, transaction
cursor = "SELECT foo FROM bar;"
connection.cursor().execute(query)
transaction.commit_unless_managed()