4paradigm / 4paradigm/OpenMLDB

Mock commit statement for open-mysql-db by using panda dataframe

未关闭
#3,850 0 条评论 0 个 reaction 已指派 1 人 已被 @yangwucheng 认领 在 GitHub 查看
主要语言
C++
星标
1.7k
派生
331
平均合并
12 天 12 小时
30 天内合并 PR
1

描述

**Describe the feature you'd like**

Now we are using sqlalchemy and pandas dataframe. The method of "to_sql" is not supported which uses commit statements.

Here is the example code.

```
import pandas as pd
from sqlalchemy import create_engine

# Create a Pandas DataFrame (replace this with your actual data)
data = {'id': [1, 2, 3],
'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35]}
df = pd.DataFrame(data)

# Create a MySQL database engine using SQLAlchemy
engine = create_engine('mysql://username:password@host/db_name')

# Replace 'username', 'password', 'host', and 'db_name' with your actual database credentials

# Define the name of the table in the database where you want to write the data
table_name = 'your_table_name'

# Write the DataFrame 'df' into the MySQL table
df.to_sql(table_name, engine, if_exists='replace', index=False)

# 'if_exists' parameter options:
# - 'fail': If the table already exists, an error will be raised.
# - 'replace': If the table already exists, it will be replaced.
# - 'append': If the table already exists, data will be appended to it.

print("Data written to MySQL table successfully!")
```

And we may get the error like this.

```
[1002] create logic plan tree failed--Un-support statement type: CommitStatement'
```

**Additional context**

Add any other context or screenshots about the feature request here.

贡献指南

打开贡献指南

调研方向

The issue is about supporting commit statements when using pandas DataFrame.to_sql with SQLAlchemy on OpenMLDB. Look at the OpenMLDB SQL engine's handling of CommitStatement. Start by searching for 'CommitStatement' in the codebase, likely in the SQL parser or planner. Check how other statement types are supported and see where commit logic needs to be added. Run the provided example to reproduce the error and verify the fix.

由索引模型根据 Issue 内容生成。

评估

技术栈
mysql, pandas, python, sqlalchemy
领域
data-engineering, databases, machine-learning
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。