db.execute_many
South 0.4 and up
db.execute_many(sql, regex=r"(?mx) ([^';]* (?:'[^']*'[^';]*)*)", comment_regex=r"(?mx) (?:^\s*$)|(?:--.*$)")
Executes the given multi-statement SQL string sql. The two parameters are the regular expressions for splitting up statements (regex) and removing comments (comment_regex). We recommend you leave these at their default values, as they work on all SQL files tried.
If you only want to execute a single SQL statement, consider using db.execute, as it offers parameter escaping.
Examples
Run the PostGIS initialisation file:
db.execute_many(open("/path/to/lwpostgis.sql").read())
