8
我知道這很簡單,但我無法得到它的工作!我沒有插入,更新或選擇命令probs,讓我說我有一個字典,我想填充一個表中的字典中的列名與我的一行添加一列的錯誤是什麼?如何添加列到sqlite3 python?
##create
con = sqlite3.connect('linksauthor.db')
c = con.cursor()
c.execute('''create table linksauthor (links text)''')
con.commit()
c.close()
##populate author columns
allauthors={'joe':1,'bla':2,'mo':3}
con = sqlite3.connect('linksauthor.db')
c = con.cursor()
for author in allauthors:
print author
print type(author)
c.execute("alter table linksauthor add column '%s' 'float'")%author ##what is wrong here?
con.commit()
c.close()
omg,謝謝lmao,我盯着代碼顯然太長 – user291071 2010-04-22 18:52:15