Skip to content

BUG: to_sql() insertion issue to Oracle DB #54274

@NKMatha

Description

@NKMatha

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 pandas as pd
from sqlalchemy import create_engine

connection_string = f"oracle+oracledb://{inst.usr}:{inst.passwd}@{inst.host}:{inst.port}/?service_name={inst.service}"
engine = create_engine(connection_string, thick_mode=True)

df = pd.read_csv('file/path.csv')


df.to_sql('table_name',engine,index = False)

Issue Description

oracledb.exceptions.NotSupportedError: DPY-3013: unsupported Python type int for database type DB_TYPE_NVARCHAR

even tried for converting all columns to df.astype(str) which is inserting Nan string in table

Expected Behavior

values to be inserted into tables with empty/null cells if Nan in df like df.to_csv() which does not save Nan in csv files.

Installed Versions

INSTALLED VERSIONS

commit : 37ea63d
python : 3.9.13.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 2.0.1
numpy : 1.24.3
pytz : 2023.3
dateutil : 2.8.2
setuptools : 58.1.0
pip : 22.0.4
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.13.2
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : 2.0.13
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO SQLto_sql, read_sql, read_sql_queryNeeds InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions