Store Dask Dataframe to a SQL table An empty table is created based on the "meta" DataFrame (and conforming to the caller's "if_exists" preference), and then each block calls pd.DataFrame.to_sql (with `if_exists="append"`). Databases supported by SQLAlchemy [1]_ are supported. Tables c
(
df,
name: str,
uri: str,
schema=None,
if_exists: str = "fail",
index: bool = True,
index_label=None,
chunksize=None,
dtype=None,
method=None,
compute=True,
parallel=False,
engine_kwargs=None,
)
| 420 | |
| 421 | |
| 422 | def to_sql( |
| 423 | df, |
| 424 | name: str, |
| 425 | uri: str, |
| 426 | schema=None, |
| 427 | if_exists: str = "fail", |
| 428 | index: bool = True, |
| 429 | index_label=None, |
| 430 | chunksize=None, |
| 431 | dtype=None, |
| 432 | method=None, |
| 433 | compute=True, |
| 434 | parallel=False, |
| 435 | engine_kwargs=None, |
| 436 | ): |
| 437 | """Store Dask Dataframe to a SQL table |
| 438 | |
| 439 | An empty table is created based on the "meta" DataFrame (and conforming to the caller's "if_exists" preference), and |
| 440 | then each block calls pd.DataFrame.to_sql (with `if_exists="append"`). |
| 441 | |
| 442 | Databases supported by SQLAlchemy [1]_ are supported. Tables can be |
| 443 | newly created, appended to, or overwritten. |
| 444 | |
| 445 | Parameters |
| 446 | ---------- |
| 447 | name : str |
| 448 | Name of SQL table. |
| 449 | uri : string |
| 450 | Full sqlalchemy URI for the database connection |
| 451 | schema : str, optional |
| 452 | Specify the schema (if database flavor supports this). If None, use |
| 453 | default schema. |
| 454 | if_exists : {'fail', 'replace', 'append'}, default 'fail' |
| 455 | How to behave if the table already exists. |
| 456 | |
| 457 | * fail: Raise a ValueError. |
| 458 | * replace: Drop the table before inserting new values. |
| 459 | * append: Insert new values to the existing table. |
| 460 | |
| 461 | index : bool, default True |
| 462 | Write DataFrame index as a column. Uses `index_label` as the column |
| 463 | name in the table. |
| 464 | index_label : str or sequence, default None |
| 465 | Column label for index column(s). If None is given (default) and |
| 466 | `index` is True, then the index names are used. |
| 467 | A sequence should be given if the DataFrame uses MultiIndex. |
| 468 | chunksize : int, optional |
| 469 | Specify the number of rows in each batch to be written at a time. |
| 470 | By default, all rows will be written at once. |
| 471 | dtype : dict or scalar, optional |
| 472 | Specifying the datatype for columns. If a dictionary is used, the |
| 473 | keys should be the column names and the values should be the |
| 474 | SQLAlchemy types or strings for the sqlite3 legacy mode. If a |
| 475 | scalar is provided, it will be applied to all columns. |
| 476 | method : {None, 'multi', callable}, optional |
| 477 | Controls the SQL insertion clause used: |
| 478 | |
| 479 | * None : Uses standard SQL ``INSERT`` clause (one per row). |
no test coverage detected
searching dependent graphs…