Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import adbc_driver_postgresql.dbapi as pg_dbapi
import pandas as pd
con = pg_dbapi.connect(uri="<PG_URI>")
table_name = "my_table"
df = pd.DataFrame({"c0": [1, 2, 3], "c1": ["foo", "boo", "bar"]})
df.to_sql(name=table_name, con=con, schema="public", if_exists="replace")
Issue Description
The table which ends up being created in the public
schema ends up being named public.my_table
, instead of just my_table
. The table is then inaccessible, as the following code throws this error ValueError: Table my_table not found
:
df_out = pd.read_sql_table(table, con, schema="public")
The created table can be found using the following code:
objects = con.adbc_get_objects(depth="tables", db_schema_filter="public", catalog_filter="postgres").read_all()
catalogs = objects.to_pylist()
all_tables = catalogs[0]["catalog_db_schemas"][0]["db_schema_tables"]
table = [x for x in all_tables if table in x["table_name"]][0]
Expected Behavior
Table gets created under the name specified, without including the schema name in the table name.
Installed Versions
pandas : 2.2.0
numpy : 1.26.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 69.1.0
pip : 24.0
Cython : None
pytest : 8.0.1
hypothesis : None
sphinx : 7.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : 1.4.6
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.12.3
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2023.12.2
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None