0

I am trying to load data from a file into a table in my mysql server using the

load data local infile '<filename>' into table <tablename> 

command but it gives the error 1148. I understand this is due to some security issues and that I have to enable local-infile option to get this command to execute.

But since I am trying to execute this through python, I am not sure how can I enable this option.

Additional Info: I am using mysqldb import for python

nik-v
  • 753
  • 1
  • 9
  • 20

1 Answers1

0

Figured it out after a bit of googling.

A couple of answers point towards the fact that I can edit

/etc/mysql/my.cnf

and add local-infile=0 in the fie

But sometimes(not sure why) python won't pick up the settings from the file.

You can pass the argument:

read_default_file="/etc/mysql/my.cnf"

while creating the connection to the database, as follows

conn = MySQLdb.connect(host='localhost',user='root',passwd='passwd',db='db',charset = "utf8", use_unicode = True,read_default_file="/etc/mysql/my.cnf")
nik-v
  • 753
  • 1
  • 9
  • 20