我想要:如果列不存在,添加列
def tablo_olustur():
cursor.execute("CREATE TABLE IF NOT EXISTS "+asin+"(Tarih TEXT)")
con.commit()
tablo_olustur()
def veri_ekle(Satıcı_ismi,Stok_Miktarı):
cursor.execute("INSERT INTO "+asin+' (Tarih, "{}") values (?,?)'.format(Satıcı_ismi),(currentDT,Stok_Miktarı))
con.commit()
#def ver_ekle2(Stok_Miktarı):
# cursor.execute("INSERT INTO "+asin+" (Satıcı_ismi, '{}') values (?,?)".format(currentDT),(Satıcı_ismi,Stok_Miktarı))
# con.commit()
def sutun_ekle(sutun):
cursor.execute("ALTER TABLE "+asin+' ADD COLUMN "{}" '.format(sutun))
con.commit()
我从python得到sqlite3.OperationalError: duplicate column name: xxxx
错误
您可以尝试这样做,如果列存在,它将添加,如果不存在,您可以检查表中是否已经存在同名的任何列
您需要检查表以查看列是否存在:
相关问题 更多 >
编程相关推荐