次のコードを書きました。私はそれを機能させるのに非常に近いので、ほとんど味と匂いを嗅ぐことができます.
私は mysql.connector、tweepy、python 3.2、および xampp スタックを使用しています。ユーザーからの最新の 3200 件のツイートを保持するための一意のテーブルを作成しています。私はそれをループで実行しており、すべての結果を画面に出力できます。まったく問題ありません。MYSQL データベースに書き込もうとすると、問題が発生します。列と同様に、テーブルは正常に作成されます。
編集:
@Yarkee と @bernie の支援を受けて、次のように編集しました。
tweet_created_date = str(tweet.created_at)
list = [tweet.id, tweet.text, tweet_created_date,
tweet.geo, tweet.contributors, tweet.coordinates,
tweet.favorited, tweet.in_reply_to_screen_name,
tweet.in_reply_to_status_id, tweet.in_reply_to_status_id_str,
tweet.in_reply_to_user_id, tweet.in_reply_to_user_id_str,
tweet.place, tweet.retweeted, tweet.retweet_count,
tweet.source, tweet.truncated]
sql = ("""INSERT INTO %(table_name)s (tweet_id, tweet_text,
tweet_created_at, tweet_geo, tweet_contributors,
tweet_coordinates, tweet_favorited,
tweet_in_reply_to_screen_name, tweet_in_reply_to_status_id,
tweet_in_reply_to_status_id_str, tweet_in_reply_to_user_id,
tweet_in_reply_to_user_id_str, tweet_place,
tweet_retweeted, tweet_retweet_count, tweet_source,
tweet_truncated) VALUES (%s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s)""" % dict(table_name=table_name))
cursor.execute(sql, list)
私は今持っていますTypeError: not enough arguments for format string
何か案は?