Skip to content

Connections executemany implementation is not a prepared statement.  #196

@martinitus

Description

@martinitus

While PEP249 says

Modules are free to implement this method using multiple calls to the .execute() method or by using array operations to have the database process the sequence as a whole in one call.

Just reading the docstring from the connection class is maximally misleading:

def executemany(self, operation, seq_of_parameters):
"""
Prepare a database operation (query or command) and then execute it against all parameter
sequences or mappings found in the sequence ``seq_of_parameters``.
Only the final result set is retained.
:returns self
"""
for parameters in seq_of_parameters:
self.execute(operation, parameters)
return self

As a user, I (of course) assumed that databricks-sql-connector does something smart like e.g. batched inserts for a insert query. Instead I find that I have many thousand sequentially executed individual insert requests, one for each row.

I suggest to change the docstring to point out that behaviour!

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