I'm trying to save a list of links, titles, etc for my rss feeder, but when I commit it it gives an error.
Here's my Python code:
class News(db.Model): __tablename__ = 'rssfeeds' id = db.Column(db.Integer, primary_key = True) links = db.Column(db.String(60), unique = True, nullable = False) titles = db.Column(db.String(100), unique = True, nullable = False) summarys = db.Column(db.Text, unique = True, nullable = False) contents = db.Column(db.Text, unique = True, nullable = False) #Dummy data my_links = ['link1', 'link2', 'link3'] my_titles = ['title1', 'title2', 'title3'] my_summary = ['summary1', 'summary2', 'summary3'] my_content = ['content1', 'content2', 'content3']
Here are the sql queries
My flask-SQLAlchemy code:
#importing python lists feed = News(links = my_links, titles = my_titles, summarys = my_summarys) db.session.add(feed) db.session.commit() #here is where i get the error
And this is the error message I get:
...... ..... _execute_context self._handle_dbapi_exception( File "C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1511, in _handle_dbapi_exception util.raise_( File "C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 178, in raise_ raise exception File "C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1277, in _execute_context self.dialect.do_execute( File "C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 593, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: rssfeeds [SQL: INSERT INTO rssfeeds (links, titles, summarys, contents) VALUES (?, ?, ?, ?)] [parameters: (['link1', 'link2', 'link3'], ['title1', 'title2', 'title3'], ['summary1', 'summary2', 'summary3'], ['content1', 'content2', 'content3'])] (Background on this error at: http://sqlalche.me/e/13/e3q8)
Thanks in advance
https://stackoverflow.com/questions/65879969/getting-error-sqlalchemy-exc-interfaceerror-sqlite3-interfaceerror-error-bin January 25, 2021 at 02:36PM
没有评论:
发表评论