尝试卸载sqlite3行时出错

时间:2015-07-01 01:56:12

标签: python sqlite

我使用python访问sqlite数据库。我正在访问Firefox cookie数据库的副本。

我试图遵循jjm给出的建议: http://stackoverflow.com/questions/12325234/python-tuple-indices-must-be-integers-not-str-when-selecting-from-mysql-table

我想将行变量解压缩为简单的变量名。我不明白我用row得到什么类型的变量。它是一个数组吗?

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,aValue,aHost,aDisplayExpire,aExpire = row" 变量debug设置为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

1 个答案:

答案 0 :(得分:0)

我切断了矢量的末尾。

aName,aValue,aHost,aDisplayExpire,aExpire = row [:5]