Python tweepy writing to sqlite3 db

后端 未结 2 1575
小鲜肉
小鲜肉 2021-01-28 16:24

My script below (taken from various resources online) isn\'t writing to the database. I do not get any errors, and if I comment out the database lines then it outputs to the co

2条回答
  •  没有蜡笔的小新
    2021-01-28 16:42

    Do you want to do this:

    cur = conn.cursor()
    cursor.execute('INSERT INTO tweets (text, date) VALUES (?, NOW())' ,(status.text))
    

    Or this:

    cur = conn.cursor()
    cur.execute('INSERT INTO tweets (text, date) VALUES (?, NOW())' ,(status.text))
    

    In the First case cursor is undeclared.

    Also, as lqc pointed out, you silence all errors. Don't catch any exceptions to see what's going on or change it to something more specific (like UnicodeError).

提交回复
热议问题