当前位置:网站首页>目前想通过提取本地excel文件创建数据表,在sql语句这出了一些问题
目前想通过提取本地excel文件创建数据表,在sql语句这出了一些问题
2022-08-02 13:12:00 【CSDN问答】
想要将本地excel文件名作为表名,表格中第一行作为字段,现在好像是sql语句不能使用变量?有帮助必采纳
def ct(request): if request.method == 'GET': return render(request, "create_table.html") if request.method == 'POST': f = request.FILES.get('file') path = r"D:\pythonProject3\bphweb\app01\static\upload_excel" # 文件夹目录 files = os.listdir(path) excel_name = files[0].split(".xlsx")[0] print(excel_name) wb = xlrd.open_workbook(filename=excel_name,file_contents=f.read()) table = wb.sheets()[0] nrow_value = table.row_values(0) print(nrow_value) ziduan_1 = nrow_value[0] ziduan_2 = nrow_value[1] ziduan_3 = nrow_value[2] from django.db import connection cursor = connection.cursor() sqll = "create table %s (%s int,%s int,%s int);" cursor.execute(sqll,[excel_name,ziduan_1,ziduan_2,ziduan_3]) return HttpResponse("建立成功")
边栏推荐
- How to turn off hardware acceleration [easy to understand]
- photo-sphere-viewer Chinese documentation
- 工厂方法模式
- Four seasons of trees realized by svg
- First acquaintance of scrapy framework 1
- Mysql视图
- Summer training camp-week2 graph theory
- 【C语言】手撕循环结构 —— for语句
- php - the first of three solid foundations
- 攻防世界----unfinish
猜你喜欢
qt 编译报错 No rule to make target
FreeRTOS experiment -- delete task
【C语言】手撕循环结构 —— for语句
3 ways for OpenFeign to set headers
Win11怎么修改关机界面颜色?Win11修改关机界面颜色的方法
Enterprise Network Planning Based on Huawei eNSP
攻防世界----unfinish
js true 3d histogram plugin
Article 48 - Analysis of timestamp2 parameters【2022-08-01】
Intouch System Platform IDE-1
随机推荐
暑假集训-week2图论
js数组递归使用
无线振弦采集仪远程修改参数方式
我的创作纪念日
leetcode 504. Base 7 七进制数 (简单)
节省50%成本!京东云重磅发布新一代混合CDN产品
网络流详解(流网图一般能够反映什么信息)
WPF效果第一百九十三篇之登录实现
How to do short video food from the media?5 steps to teach you to get started quickly
this的绑定指向详细解答
Enterprise Network Planning Based on Huawei eNSP
工厂方法模式
UAC绕过学习-总结
js semi-circle loading progress animation js special effects
Four seasons of trees realized by svg
Detailed explanation of network flow (what information can the flow network diagram generally reflect)
路由-Tab切换页面
企业用直播平台能实现什么
C语言结构体(入门)
动态组件-component