tweepy stream to sqlite database - invalid synatx

后端 未结 4 1788
你的背包
你的背包 2021-01-07 10:05

The code below is streaming the twitter public timeline for a variable which output any tweets to the console. I\'d like the save the same variables (status.text, status.aut

4条回答
  •  无人及你
    2021-01-07 10:37

    Full disclosure: still new to this stuff. However, I got your code working by changing it to:

    cur.execute("INSERT INTO TWEETS VALUES(?,?,?,?)", (status.text, status.author.screen_name, status.created_at, status.source))
    con.commit()
    

    It seems to me that you're reading in one status at a time. The executemany method would be for when you have more than one status. For example:

    (['sometext', 'bob','2013-02-01','Twitter for Android'], ['someothertext', 'helga', '2013-01-31', 'MacSomething'])

    I'm definitely not a wizard and am not sure what sort of impact the commit() has on every entry... I'm guessing the performance is terrible, but it works for a single term in the query.

    Thanks for posting your code, I finally learned how to do streaming.

提交回复
热议问题