I would like to execute the MySQL query source FileName.sql
in a Python script on Linux.
I am able to execute other queries like SELECT * FROM table_name
but this one is giving an error. I am executing this on a Linux server with a MySQL database using Python. The frontend I am using is Putty.
The Python script I have used is:
import MySQLdb
db = MySQLdb.connect("hostname","username","pswrd","dbname")
cursor = db.cursor()
cursor.execute("source FileName.sql")
db.close()
How can I execute the query source FileName.sql
on the location where this file-> FileName.sql
is located?