2
我目前正在研究一個需要推文並進行快速情緒分析並加載推文ID,推文日期,推文文本以及推文情緒的項目極性插入MS Access表(Office 2013)。我已將輸出轉換爲字符串,但情感極性與表(Test)數據類型相匹配。這裏是我的代碼:PYODBC MS Access插入錯誤 - 太少參數
from pattern.web import Twitter
import time
import pyodbc
from textblob import TextBlob
cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:...SentimentAnalysis.accdb;')
cursor = cnxn.cursor()
s = Twitter().stream('#testhash')
for i in range(25):
time.sleep(1)
s.update(bytes=1024)
if s:
Ident = str(s[-1].id)
TweetDate = str(s[-1].date)
TweetText = str(s[-1].text.encode('utf8'))
x = s[-1].text
blob = TextBlob(x)
sent = blob.sentiment.polarity
cursor.execute('insert into Test([Ident],[TweetDate],[TweetText],[TweetSentiment]) values (Ident,TweetDate,TweetText,sent);')
cnxn.commit()
print 'Inserted: ', Ident
else: ''
s.clear()
的問題是,我得到以下錯誤:
pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4. (-3010) (SQLExecDirectW)')
我見過的其他職位上的這個錯誤,但大多數都只是是由於在雙引號問題訪問。由於我只用了單引號,仍然遇到問題,所以我很難過。這讓我瘋狂!任何幫助將不勝感激!
這工作完美戈登!謝謝! – swaters