how to execute external sql file in mariadb using python

  mysql-connector, mysql-python, python

How to execute this line in python

from os import system
USERNAME = "root"
PASSWORD = "root"
DBNAME = "classicmodels"
HOST = "localhost"
PORT = 3306
FILE = "mysqlsampledatabase.sql"
command = """MariaDB -u %s -p"%s" --host %s --port %s %s < %s""" %(USERNAME, PASSWORD, HOST, PORT, DBNAME, FILE)
system(command)

or how to execute external SQL files in mariadb using python

Source: Python Questions

LEAVE A COMMENT