Prepares table in the database for data insertion. Creates it if needed, etc.
(
self,
frame,
name: str,
if_exists: Literal["fail", "replace", "append", "delete_rows"] = "fail",
index: bool | str | list[str] | None = True,
index_label=None,
schema=None,
dtype: DtypeArg | None = None,
)
| 1885 | read_sql = read_query |
| 1886 | |
| 1887 | def prep_table( |
| 1888 | self, |
| 1889 | frame, |
| 1890 | name: str, |
| 1891 | if_exists: Literal["fail", "replace", "append", "delete_rows"] = "fail", |
| 1892 | index: bool | str | list[str] | None = True, |
| 1893 | index_label=None, |
| 1894 | schema=None, |
| 1895 | dtype: DtypeArg | None = None, |
| 1896 | ) -> SQLTable: |
| 1897 | """ |
| 1898 | Prepares table in the database for data insertion. Creates it if needed, etc. |
| 1899 | """ |
| 1900 | if dtype: |
| 1901 | if not is_dict_like(dtype): |
| 1902 | # error: Value expression in dictionary comprehension has incompatible |
| 1903 | # type "Union[ExtensionDtype, str, dtype[Any], Type[object], |
| 1904 | # Dict[Hashable, Union[ExtensionDtype, Union[str, dtype[Any]], |
| 1905 | # Type[str], Type[float], Type[int], Type[complex], Type[bool], |
| 1906 | # Type[object]]]]"; expected type "Union[ExtensionDtype, str, |
| 1907 | # dtype[Any], Type[object]]" |
| 1908 | dtype = dict.fromkeys(frame, dtype) # type: ignore[arg-type] |
| 1909 | else: |
| 1910 | dtype = cast(dict, dtype) |
| 1911 | |
| 1912 | from sqlalchemy.types import TypeEngine |
| 1913 | |
| 1914 | for col, my_type in dtype.items(): |
| 1915 | if isinstance(my_type, type) and issubclass(my_type, TypeEngine): |
| 1916 | pass |
| 1917 | elif isinstance(my_type, TypeEngine): |
| 1918 | pass |
| 1919 | else: |
| 1920 | raise ValueError(f"The type of {col} is not a SQLAlchemy type") |
| 1921 | |
| 1922 | table = SQLTable( |
| 1923 | name, |
| 1924 | self, |
| 1925 | frame=frame, |
| 1926 | index=index, |
| 1927 | if_exists=if_exists, |
| 1928 | index_label=index_label, |
| 1929 | schema=schema, |
| 1930 | dtype=dtype, |
| 1931 | ) |
| 1932 | table.create() |
| 1933 | return table |
| 1934 | |
| 1935 | def check_case_sensitive( |
| 1936 | self, |
no test coverage detected