Import Twitter*より、TwitterAPIをSQLデータベースに移したいと考えています。
サイトリンク内容を参考にしたスクリプトと
書籍:「Twitterの空間分析」より以下の画像のスクリプトを合わせて、
APIより取得したデータのうちid,text,geo.coodinateを
SQLのtwitterdbのテーブルであるtwitteruserのid,text,geo.coodinateに
それぞれ移したいのですが、エラーとなってしまいます。
#API情報の取得 >>> from twitter import * >>> auth = OAuth( ... consumer_key='000', ... consumer_secret='000', ... token='000', ... token_secret='000' ... ) >>> params = dict() >>> params["locations"] = "000, 000, 000, 000" >>> twitter_stream = TwitterStream(auth=auth, domain='stream.twitter.com') #SQLへの接続、データの移動 >>> import psycopg2 >>> conn = psycopg2.connect(host='localhost', dbname='twitterdb', user='postgres', password='000', port='5432') >>> cur = conn.cursor() >>> command = '''INSERT INTO twitterdb (id, text, geo.coordinate) VALUES (%s,%s,%s) ON CONFLICT ... (User_Id) DO NOTHING;''' >>> cur.execute(command,(id,text,geo.coodinate)) #エラー内容 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'text' is not defined
エラー内容からtext等の定義がされていないためだと思うのですが、この場合id,text,
geocoodinateを何に定義すればよいのでしょうか。
また、ここで定義されるtext等はTwitterAPIからとってきた情報のことでしょうか?それともSQLtable名のtextでしょうか。
あなたの回答
tips
プレビュー