8000 DOC: Document existing functionality of pandas.DataFrame.to_sql() #11886 by oguzhanogreden · Pull Request #26795 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DOC: Document existing functionality of pandas.DataFrame.to_sql() #11886 #26795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Aug 30, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add type checking only imports
  • Loading branch information
oguzhanogreden committed Jun 17, 2019
commit 82ebc5c6bafe67affd6b6f15bee46bf59a88d0b8
21 changes: 16 additions & 5 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import operator
import pickle
from textwrap import dedent
from typing import Any, Callable, FrozenSet, Iterator, List, Set, Union
from typing import (
TYPE_CHECKING, Callable, FrozenSet, Iterator, List, Set, Union)
import warnings
import weakref

Expand Down Expand Up @@ -51,6 +52,12 @@
from pandas.io.formats.printing import pprint_thing
from pandas.tseries.frequencies import to_offset

if TYPE_CHECKING:
import sqlalchemy # noqa: F401
import sqlite3 # noqa: F401

from pandas.io.sql import SQLTable # noqa: F401

# mypy confuses the `bool()`` method of NDFrame
_bool = bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea this is unfortunate and something we've seen before:

#26029 (comment)

The alias is the suggested approach so no change required here I think, but cc @jreback for visibility


Expand Down Expand Up @@ -2468,15 +2475,19 @@ def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs):
# dependency.
def to_sql(self,
name: str,
con: Any,
con: Union['sqlalchemy.engine.Engine', 'sqlite3.Connection'],
schema: str = None,
if_exists: str = 'fail',
index: _bool = True,
index_label: Union[str, List[str]] = None,
chunksize: int = None,
dtype: Dtype = None,
method: Union[str, Callable[[Any, Any, List[str],
Iterator[List]], None]] = None
method: Union[str,
Callable[['SQLTable',
Union['sqlalchemy.engine.Engine',
'sqlite3.Connection'],
List[str], Iterator[List]], None]
] = None
) -> None:
"""
Write records stored in a DataFrame to a SQL database.
Expand Down Expand Up @@ -2521,7 +2532,7 @@ def to_sql(self,

* None : Uses standard SQL ``INSERT`` clause (one per row).
* 'multi': Pass multiple values in a single ``INSERT`` clause.
* callable with signature ``(pd_table, conn, keys, data_iter)``.
* callable with signature ``(pd_table, con, keys, data_iter)``.

Details and a sample callable implementation can be found in the
section :ref:`insert method <io.sql.method>`.
Expand Down
0