我正在使用python來訪問sqlite數據庫。我正在訪問Firefox Cookie數據庫的副本。嘗試解壓sqlite3行時出錯
我想照做在給這裏由朱鎮模: http://stackoverflow.com/questions/12325234/python-tuple-indices-must-be-integers-not-str-when-selecting-from-mysql-table
我想行變量解壓到簡單的變量名。我不明白我使用的是哪種類型的變量。它是一個數組嗎?
with con:
cur = con.cursor()
#
cur.execute("SELECT \
name, \
value, \
host, \
datetime((expiry/1000000), 'unixepoch'), \
expiry, \
datetime((lastAccessed/1000000), 'unixepoch'), \
datetime((creationTime/1000000), 'unixepoch') \
FROM moz_cookies \
WHERE baseDomain = 'apple.com' AND name = 's_ppv'")
rows = cur.fetchall()
print (len(rows))
for row in rows:
if debug >= 1:
# Indexes are 0 offset.
print ("row is = ")
print (row)
aName, aValue, aHost, aDisplayExpire, aExpire = row
失敗的 「aName,安勤,aHost,aDisplayExpire,aExpire =行」 變量調試被設置爲1 這裏是輸出。
1
row is =
(u's_ppv', u'acs%253A%253Aadf%253A%253Aprofile%253Auser%2520profile%2520%2528en_US%2529%2C78%2C78%2C576%2C', u'.apple.com', u'2015-07-01 01:47:46', 1435715266000000L, u'2015-07-01 01:27:46', u'2015-06-15 16:12:15')
Traceback (most recent call last):
File "./adjust-ASC-Time.bash", line 188, in <module>
aName, aValue, aHost, aDisplayExpire, aExpire = row
ValueError: too many values to unpack
您選擇7列但拆包到只有5個值。 –