Execute .sql file in Python with MySQLdb
I have a .sql file containing a bunch of SQL queries, with each query spanning multiple lines. I want to execute these queries in MySQL via Python using MySQLdb . sqlite3 has "a nonstandard shortcut" for this purpose called executescript() , but there doesn't seem to be any equivalent function in MySQLdb . I noticed this old question from 2 years ago which asks the same thing, but I found the answers unsatisfying. The answers are basically: Use subprocess to run the mysql command and send it your .sql file. This works, but it is rather inelegant, and it introduces unwanted complexity with