当前位置:网站首页>目前想通过提取本地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("建立成功")
边栏推荐
- php - the first of three solid foundations
- RESTful 风格(详细介绍 + 案例实现)
- Set proxy server (Google+IE) "Recommended Collection"
- Scala基础语法入门(三)Scala中的各种运算符
- Redis all
- Interpretation of new features | MySQL 8.0 GIPK invisible primary key
- How to do short video food from the media?5 steps to teach you to get started quickly
- Article 48 - Analysis of timestamp2 parameters【2022-08-01】
- 【C语言】夏日一题 —— 如何判断素数?
- Intouch System Platform IDE-1
猜你喜欢
随机推荐
js stopwatch countdown plugin
ESP8266模块使用完整教程「建议收藏」
冰箱“扩容”的战事,在今夏格外猛烈
永远退出机器学习界!
There are several ways to jump to js source code, jump on the current page, jump on the blank page
短视频美食自媒体怎么做?5步教你快速上手
[typescript] Use the RangePicker component in antd to implement time limit the previous year (365 days) of the current time
Introduction to Scala Basic Syntax (3) Various Operators in Scala
3 ways for OpenFeign to set headers
企业用直播平台能实现什么
Oracle update误操作单表回滚
Mysql索引详解(图文并茂)
基于flask商城的管理员功能
Singleton pattern of seven kinds of writing, you know?
Do you know Dijkstra of graph theory?
麻烦问一下,对mysql 场景注入故障,是不是不是对mysql server 端注入故障,只是对ja
Js scratchable latex style draw plug-in
图论之Kruskal,最小生成树如何优雅解题?
pytorch model to tensorflow model
GCC版本升级到指定版本