当前位置:网站首页>目前想通过提取本地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("建立成功")边栏推荐
- Introduction to Scala Basic Syntax (3) Various Operators in Scala
- 国产 GPU 创业潮 喧嚣下的资本游戏
- package.json and package-lock.json
- Good shooting js game source code
- Oracle update error operation single table rollback
- 基于华为eNSP的企业网络规划
- Get out of the machine learning world forever!
- 最小割和对偶图(未完成)
- How to turn off hardware acceleration [easy to understand]
- js数组递归使用
猜你喜欢
随机推荐
【typescript】使用antd中RangePicker组件实现时间限制 当前时间的前一年(365天)
永远退出机器学习界!
This binding to detailed answers
sql concat() function
Openlayers Quick Start Tutorial
冰箱“扩容”的战事,在今夏格外猛烈
Basic operations of openGauss database (super detailed)
SQL Server 2019 installation error 0 x80004005 service there is no timely response to the start or control request a detailed solution
Closures in JS
【C语言】手把手带你写游戏 —— 猜数字
微信小程序getPhoneNumber接口code=40013
MFC入门教程(深入浅出MFC)
水平垂直居中方式
Intouch Historian历史曲线配置导入导出
SQL Server database generation and execution of SQL scripts
读《IDEO,设计改变一切》有感
Redis全部
Enterprise Network Planning Based on Huawei eNSP
图论之Prim,最小生成树该怎么解?
.Net 5.0 Quick Start Redis









