[PYTHON] LOAD DATA with PyMysql

When I tried to execute LOAD DATA with pymysql as shown below

python


def load_data(file_path):
    with conn.cursor() as cursor:
        sql = """
LOAD DATA LOCAL INFILE '{}' 
INTO TABLE Sample 
CHARACTER SET utf8 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
LINES TERMINATED BY '\n' 
IGNORE 1 LINES 
        """.format(file_path)
        cursor.execute(sql)

I got the following error and could not import.

pymysql.err.InternalError: (1148, 'The used command is not allowed with this MySQL version')

It was solved by specifying local_infile = True at the time of connect.

python


pymysql.connect(
    :
    local_infile=True
)

Recommended Posts

LOAD DATA with PyMysql
Data analysis with python 2
Reading data with TensorFlow
Data visualization with pandas
Data manipulation with Pandas!
Shuffle data with pandas
Data Augmentation with openCV
Normarize data with Scipy
Data analysis with Python
Embed audio data with Jupyter
Graph Excel data with matplotlib (1)
Load nested json with pandas
Artificial data generation with numpy
Extract Twitter data with CSV
Clustering ID-POS data with LDA
Learn new data with PaintsChainer
Binarize photo data with OpenCV
Graph Excel data with matplotlib (2)
Load test Websocket with Locust
Data processing tips with Pandas
Interpolate 2D data with scipy.interpolate.griddata
Read json data with python
Load Django modules with an interpreter
How to deal with imbalanced data
How to deal with imbalanced data
[Python] Get economic data with DataReader
Python data structures learned with chemoinformatics
Parse pcap data with tshark command
How to Data Augmentation with PyTorch
Load gif images with Python + OpenCV
Easy data visualization with Python seaborn.
Generate fake table data with GAN
Process Pubmed .xml data with python
Data analysis starting with python (data visualization 1)
Manage your data with AWS RDS
Try data parallelism with Distributed TensorFlow
Data analysis starting with python (data visualization 2)
Merge JSON format data with Ansible
Implement "Data Visualization Design # 2" with matplotlib
Python application: Data cleansing # 2: Data cleansing with DataFrame
Subtitle data created with Amazon Transcribe
Forecasting time series data with Simplex Projection
Data accumulation with GCP's permanent free frame
Get additional data in LDAP with python
Data pipeline construction with Python and Luigi
Receive textual data from mysql with python
[Note] Get data from PostgreSQL with Python
Load csv with duplicate columns in pandas
Predict time series data with neural network
Learn data distributed with TensorFlow Y = 2X
Process Pubmed .xml data with python [Part 2]
Add a Python data source with Redash
Retrieving food data with Amazon API (Python)
Try working with binary data in Python
Generate Japanese test data with Python faker
I tried factor analysis with Titanic data!
Get data from Cloudant with Bluemix flask
Convert Excel data to JSON with python
Load macros like usepackage with sphinx + mathjax
[Python] Use string data with scikit-learn SVM
Download Japanese stock price data with python