I have a problem that, in the bash profile, I was doing select 2 columns from a table and filtering all data which the framework column value is java into testcases file. But I want to use that python, I tried a lot of ways but without any success.
echo "select class, testcase from test_cases where framework = 'Java';" | mysql -h vm.dev.midasplayer.com --ssl-mode=DISABLED -u ${DB_USER} -p${DB_PASSWORD} tabletest > testcases
I try using the following python to connect the DB but then how to perform the SQL query and then import it into a file? Any help here will be much appreciated
import mysql.connector
mydb = mysql.connector.connect(
host="vm.dev.midasplayer.com",
user="username",
password="password"
)
print(mydb)