環境
Python3.6.0
Flask
macOS Sierra
##やりたいこと
作成したテーブルに「http://hogehoge.com」等のURLをINSERTしたい
##エラー内容
python
1<略> 2class Database(): 3 def __init__(self): 4 self.dbpath = os.path.join(app.root_path, 'database.db') 5 self.connection = sqlite3.connect(self.dbpath) 6 self.connection.isolation_level = None 7 self.cursor = self.connection.cursor() 8 def insert(self,url,img_src,title,description,count): 9 connection=self.connection 10 cursor=self.cursor 11 cursor.execute("INSERT INTO url_list VALUES (%s,%s,%s,%s,%s)" % (url,img_src,title,description,count)) 12 connection.commit() 13 connection.close() 14 15Data=Database() 16Data.insert('http://hoge.com',"img.jpg","タイトル","ディスクリプション",1)
実行すると、以下のエラーが発生します。
sqlite3.OperationalError: unrecognized token: ":"
そして、「:」を消すと次は
sqlite3.OperationalError: near "/": syntax error
さらに、「/」を決してみると次は
sqlite3.OperationalError: no such column: httphoge.com ←:も/も消したやつ
となってしまいます。
どん詰まりです。
どなたか、ご教授くださいませ・・・・・・。
追記:
ちなみに、
cursor.execute("INSERT INTO url_list VALUES (%s,%s,%s,%s,%s)" % (url,img_src,title,description,count))
の部分を
cursor.execute("INSERT INTO url_list VALUES (url,img_src,title,description,count)")
に直してみたところ、以下のエラーになりました。
sqlite3.OperationalError: no such column: url
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/06 13:35
2017/03/06 13:39
2017/03/06 13:45
2017/03/06 13:52
2017/03/06 13:54
2017/03/06 13:57