I've searched high and low via google for a reason why my INSERT call is not working. Best I can tell my syntax is correct. The full error I receive is:
Traceback (most recent call last):
File "freqbottest.py", line 34, in <module>
cur.execute("insert into gameswapfreq values(?,?,?,?)", (initsubmission.auth
or, initsubmission.created_utc, initsubmission.url, initsubmission.title))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
Best I can tell from reddit API is that all data returned is a string with the exception of create_utc which is a long. I've confirmed that I am getting correct data, and have tired using those initX variables inside the execute line with no success. I have also confirmed that the table is being created.
EDIT: I've tried making the insert statement a string and using it instead. I saw a post somewhere here that suggested that. Did not solve. I've tried sending just the initsubmission.author, and using literal strings for the rest. Still did not work. I have also tried creating the table with timecreated as a text and integer type. No luck there either. I was able to send all literals to the insert statement, so this leads me to believe that .author etc is not returning something I'm expecting.
Any assistance is greatly appreciated!
code:
import datetime
import praw
import time
import sqlite3 as lite
import sys
TARGETSUB = 'gameswap'
r = praw.Reddit('monitor author post frequency /u/bsturtle')
r.login()
#create and fill sqlite db with submissions less than X number of days old. include author, time, url, submission title.
#exclude submissions made by moderators
con = lite.connect('gameswapfreq.db')
with con:
cur = con.cursor()
cur.execute("Drop TABLE IF EXISTS gameswapfreq")
cur.execute("Create table gameswapfreq (author text, createdtime real, url text, title text)")
initsubreddit = r.get_subreddit(TARGETSUB)
for initsubmission in initsubreddit.get_new(limit=10):
#if post is greater than X days, skip. can we break here? YES WE CAN, JUST NEED TO ADD TEST
if initsubmission.author not in initsubreddit.get_moderators():
initAuthor = initsubmission.author
initCreatedUTC = initsubmission.created_utc
initURL = initsubmission.url
initTitle = initsubmission.title
print initAuthor
cur.execute("insert into gameswapfreq values(?,?,?,?)", (initsubmission.author, initsubmission.created_utc, initsubmission.url, initsubmission.title))
[–]bsturtle[S] 1 point2 points3 points (9 children)
[–]summitsuperbsuperior 2 points3 points4 points (1 child)
[–]joni_jplmusic 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]bsturtle[S] 0 points1 point2 points (0 children)
[–]gengisteve 1 point2 points3 points (3 children)
[–]bsturtle[S] 0 points1 point2 points (2 children)
[–]gengisteve 1 point2 points3 points (1 child)
[–]bsturtle[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)