0
我在Ubuntu中使用Web2py和sqlite Db。 Iweb2py,用戶輸入帖子的項目到一個SQLite數據庫,如「你好世界」如下: 在控制器默認的項目過帳到ThisDb如下:如何解決Sqlite數據庫索引錯誤
consult = db.consult(id) or redirect(URL('index'))
form1 = [consult.body]
form5 = form1#.split()
name3 = ' '.join(form5)
conn = sqlite3.connect("ThisDb.db")
c = conn.cursor()
conn.execute("INSERT INTO INPUT (NAME) VALUES (?);", (name3,))
conn.commit()
另一個代碼選秀權還是應該閱讀項目從ThisDb,在這種情況下的 'Hello World',如下所示:
location = ""
conn = sqlite3.connect("ThisDb.db")
c = conn.cursor()
c.execute('select * from input')
c.execute("select MAX(rowid) from [input];")
for rowid in c:break
for elem in rowid:
m = elem
c.execute("SELECT * FROM input WHERE rowid = ?", (m,))
for row in c:break
location = row[1]
name = location.lower().split()
表 '輸入',其中的Hello World」應該讀我的數據庫配置是這樣的:
CREATE TABLE `INPUT` (
`NAME` TEXT
);
此代碼先前工作良好,而Windows7和10編碼,但我有這個問題離子Ubuntu 16.04。並且我不斷收到此錯誤:
File "applications/britamintell/modules/xxxxxx/define/yyyy0.py", line 20, in xxxdefinition
location = row[1]
IndexError: tuple index out of range