带Pandas的sqlite,使用Pandas添加新列,并尝试使用具有新列的相同表更改现有表

ht4b089n  于 2023-01-13  发布在  SQLite
关注(0)|答案(1)|浏览(97)
import sqlite3
import pandas as pd
db=sqlite3.connect('School.sqlite')  //School.sqlite is a files name

data=pd.read_sql_query("select * from student",db) 
data["Address"]="TEST"  // adding new column in data dataframe 

//Student table is already exists
data.to_sql('Student',db,if_exists='replace')  // this line show error

//error show:  OperationalError: table "Student" already exists

根据我的理解,我写了正确的代码,但它仍然显示错误,

hjzp0vay

hjzp0vay1#

在sqlite数据库的to_sql方法中,表名参数是case sensitive

相关问题