Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb as mdb
- import datetime, time
- def run_sql_file(filename, connection):
- start = time.time()
- file = open(filename, 'r')
- sql = s = " ".join(file.readlines())
- print ("Start executing: " + filename + " at " + str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) + "\n" + sql )
- cursor = connection.cursor()
- cursor.execute(sql)
- connection.commit()
- end = time.time()
- print ("Time elapsed to run the query:")
- print (str((end - start)*1000) + ' ms')
- def main():
- connection = mdb.connect('127.0.0.1', 'root', 'admin', 'dbcrawlermerlot')
- run_sql_file("DBMERLOT-04-2015.sql", connection)
- connection.close()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement