[問題] SQLite3 將資料存在資料庫中

作者: xy210742 (Sam)   2018-07-14 19:25:16
各位大大好 小弟非本科系生 目前自學Python3
程式碼如下:(Python3.6)
import sqlite3
with sqlite3.connect('c.sqlite') as db:
c.to_sql('c',con=db,self.if_exists='append')
(c這資料是用pandas將台銀牌告匯率爬取下來,參考如下網址:
https://www.youtube.com/watch?v=-c5rrzjsN34)
錯誤:
File "<ipython-input-56-246156207101>", line 3
c.to_sql('c',con=db,self.if_exists='append')
^
SyntaxError: keyword can't be an expression
題目只是單純將c這資料存在資料庫中
另若是把self.拿掉
則出現以下錯誤:
OperationalError Traceback (most recent call last)
<ipython-input-57-e5a3883ff452> in <module>()
1 import sqlite3
2 with sqlite3.connect('c.sqlite') as db:
作者: Raymond0710 (雷門)   2018-07-14 19:35:00
不用self吧
作者: kenduest (小州)   2018-07-15 06:44:00
怎麼感覺看到 pandas 語法,是不是整個搞錯了你的程式碼也不完整,建議整個張貼好確認

Links booklink

Contact Us: admin [ a t ] ucptt.com