Question: mySQL, Python I am trying to write a query to write mySQL table to .csv file and I keep getting error. How can I accomplish

mySQL, Python

I am trying to write a query to write mySQL table to .csv file and I keep getting error. How can I accomplish this?

mySQL, Python I am trying to write a query to write mySQL

import mysql.connector def write_to_csv(): try: mydb = mysql.connector.connect ( user - 'root', password = 'password', database. 'Expenses', host = '127.0.0.1', allow_local_infile = 1 ) 8 11 12 13 14 16 16 12 myc = mydb.cursor() val = f "SELECT * FROM Expenses INTO OUTFILE 'users/user/databases/mysql/exp.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY ' ';" myc.execute(val) mydb.commit() mydb.close() print("The file has been created") 18 19 20 21 22 except mysql.connector.Error as error: print("parameterized query failed {}".format(error)) 23 24 25 write_to_csv) Filter All Output parameterized query failed 1290 (HY900): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!