2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-16 01:22:20 +00:00
Files
mysql/test/common/run_sql.py
2020-04-16 17:54:49 +01:00

19 lines
415 B
Python

from subprocess import run
import os
from sys import argv
def get_executable_name(name):
if os.name == 'nt':
name += '.exe'
return name
def run_sql_file(fname):
print('Running SQL file: {}'.format(fname))
with open(fname, 'rb') as f:
sql = f.read()
run([get_executable_name('mysql'), '-u', 'root'], input=sql, check=True)
if __name__ == '__main__':
run_sql_file(argv[1])