I am trying to create an instance of a table with the following code:
c = 'dcoh92j'
new_comment = Comment(rcomment = c, rtime = datetime.datetime.now())
But I receive this error:
sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 0 - probably unsupported type. [SQL: 'INSERT INTO comments (rcomment, rtime) VALUES (?, ?)'] [parameters: (Comment(id='dcoh92j'), datetime.datetime(2017, 1, 20, 12, 38, 38, 836433))
Here is my table schema:
class Comment(Base):
__tablename__ = 'comments'
id = Column(Integer, Sequence('comment_id_seq'), primary_key=True)
rcomment = Column(String)
rtime = Column(String)
def __repr__(self):
return "<Comment(rcomment='{0}', rtime='(1)')>".format(self.rcomment, self.rtime)
(Comment(id='dcoh92j'), datetime.datetime(2017, 1, 20, 12, 38, 38, 836433)
? Instead of just 'dcoh92j'
and 2017, 1, 20, 12, 38, 38, 836433
Comment(id='dcoh92j')
coming from?Full code here.
Okay I ended up figuring it out. Of course after 3 hours of bug testing and ripping out my hair, it was a simple matter of wrapping c
and datetime.datetime.now()
in str() tags.
Fix:
new_comment = Comment(rcomment = str(c), rtime = str(datetime.datetime.now()))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With