sqlite3 将excel表读入数据库

编程入门 行业动态 更新时间:2024-10-27 16:35:44

sqlite3 将excel表读入<a href=https://www.elefans.com/category/jswz/34/1771350.html style=数据库"/>

sqlite3 将excel表读入数据库

实现:将场外衍生品账户资金状况汇总表.xlsx写入mytest.db数据库

import pandas as pd
import sqlite3
# sqlite3创建数据库
conn=sqlite3.connect("mytest.db")
cursor=conn.cursor()
# sql="create table students(name text,username text,id int)"
# cursor.execute(sql)
file_path=r"D:\workspeces\各项目\db_project\场外衍生品账户资金状况汇总表.xlsx"
data=pd.read_excel(file_path)
data.to_sql("场外衍生品账户资金状况汇总表",con=conn,if_exists='append',index=False)
cursor.close()

更多推荐

sqlite3 将excel表读入数据库

本文发布于:2024-03-11 18:49:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1729645.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!