Skip to content

to_sql is very slow for sql server with sqlalchemy #23274

Closed
@anjsudh

Description

@anjsudh

df.to_sql is very slow, and takes hours, when connecting to sql server using sql alchemy connection
https://github.com/mkleehammer/pyodbc/wiki/Features-beyond-the-DB-API#fast_executemany

Performance is much faster after using fast_executemany

@event.listens_for(engine_local, 'before_cursor_execute')
def receive_before_cursor_execute(conn, cursor, statement, params, context, executemany):
    if executemany:
        cursor.fast_executemany = True

Can enable fast_executemany in to_sql implementation for SQL Server

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