Closed amotl closed 1 year ago
I think those are the relevant pointers to the corresponding SQLAlchemy documentation.
A minimal reproducible example, using pandas, is:
import pandas as pd
import sqlalchemy as sa
df = pd.DataFrame.from_records([{"foo": "baz", "bar": "qux"}])
engine = sa.create_engine("crate://localhost:4200", echo=True)
df.to_sql(name="foo", con=engine, if_exists="replace", index=False, method="multi")
A corresponding example using SQLAlchemy only, is [^1]:
import sqlalchemy as sa
metadata = sa.MetaData()
table = sa.Table(
"testdrive",
metadata,
sa.Column("foo", sa.String),
)
insertable = table.insert().values([{"foo": "bar"}])
engine = sa.create_engine("crate://", echo=True)
table.drop(bind=engine, checkfirst=True)
table.create(bind=engine)
with engine.begin() as conn:
conn.execute(insertable)
While working on this, crate/sqlalchemy-cratedb#97 has also been discovered, which is related, but not the same.
[^1]: A full program can be found at sqlalchemy_efficient_inserts.py
.
There is now a fix for this issue.
Looks like it is fixed.
Hi,
when evaluating loading Dask DataFrames into CrateDB using the
method="multi"
option, the program croaks.With kind regards, Andreas.