如何使用 python 通过获取用户输入的列名在 mysql 中添加列

问题描述 投票:0回答:1

如何通过询问用户输入并使用 python 在 mysql 中添加列来添加一列或多列?

我尝试使用 for 循环和 %s 但这似乎在这里不起作用

python mysql pandas numpy jupyter
1个回答
0
投票
#try this
name_table="beep"
table_structure=("big","small")
e="create table"+name_table+"("
table_structure=list(table_structure)
for i in range(len(table_structure)):
    e=e+' '+table_structure[i]+' varchar(50),'   
g=e[0:-1]
g=g+')'
mycursor.execute(g)
mycon.commit()
© www.soinside.com 2019 - 2024. All rights reserved.