Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: to_sql works only for strings #61385

Open
Labels
Bug IO SQLto_sql, read_sql, read_sql_query Needs InfoClarification about behavior needed to assess issue
@pdojs

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 panda as pd
from sqlalchemy.types import DOUBLE
data = # Panda Datafrme with timestamp, double and string along with different column types.
column_types_filtered_data = {col: DOUBLE() for col in data.columns}
data.to_sql(..., dtype=column_types_filtered_data)

Issue Description

For any type other than str this block in pandas.io.sql will fail.

for col, my_type in dtype.items():
 if not isinstance(my_type, str):
 raise ValueError(f"{col} ({my_type}) not a string")

Expected Behavior

Different datatypes should be supported.

Installed Versions

pandas==2.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug IO SQLto_sql, read_sql, read_sql_query Needs 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

        AltStyle によって変換されたページ (->オリジナル) /