Ticket #12941: django-multidb-cursor.diff

File django-multidb-cursor.diff, 684 bytes (added by Alex Gaynor, 14 years ago)
  • docs/topics/db/sql.txt

    diff --git a/docs/topics/db/sql.txt b/docs/topics/db/sql.txt
    index 5ec0485..a8ff88a 100644
    a b is required. For example::  
    220220
    221221        return row
    222222
     223
     224If you are using more than one database you'll need to get the connection and
     225cursor for the right database.  Django provides a ``connections`` object which
     226is a dictionary-like object that lets you get connections by their alias::
     227   
     228    def my_custom_sql(alias):
     229        from django.db import connections
     230       
     231        cursor = connections[alias].cursor()
     232        # ... execute SQL
     233
     234
    223235.. _transactions-and-raw-sql:
    224236
    225237Transactions and raw SQL
Back to Top