I'm trying to use Python 3.9.9 and subprocess to drive a MySQL import like this:
with open("./dump.sql") as f:
import_db = subprocess.run([
"mysql",
"--user=me",
"--password=password",
"--host=127.0.0.1",
"db_name"
], check=True, stdin=f)
print(import_db)
It is running without error, but the data is not being imported:
mysql: [Warning] Using a password on the command line interface can be insecure.
CompletedProcess(args=['mysql', '--user=me', '--password=password', '--host=127.0.0.1', 'db_name'], returncode=0)
Checking the database after, and db_name is not present. I've tried a few different ways of passing stdin without luck.
Any help is appreciated! Thanks!