Skip to content

Pymysql fail to use LOAD DATA LOCAL INFILE  #407

@bioinfornatics

Description

@bioinfornatics

Dear,
I would like to use pymysql with sqlachemy (python3) to load a local file. Thus I execute this statement:

    metadata = Base.metadata
    SessionMaker = sessionmaker(bind=engine)
    session = SessionMaker()
    query = "LOAD DATA LOCAL INFILE {} INTO TABLE Sequence_String FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'".format( SS_file_name )
    session.execute( query )
    session.flush()

But an error is raised:

sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tmp_file_SS_table.txt INTO TABLE Sequence_String FIELDS TERMINATED BY '\t' LINES ' at line 1") [SQL: "LOAD DATA LOCAL INFILE tmp_file_SS_table.txt INTO TABLE Sequence_String FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'"]

I tried with another engine mysqldb instead of pymysql and works as expected.

Any help are welcome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions