MySQL数据库的Python时间函数
使用Python,我将插入MySQL数据库的推文流化。 在这里,date列具有datetime类型。 使用这些库:MySQL数据库的Python时间函数,python,mysql,json,python-2.7,twitter,Python,Mysql,Json,Python 2.7,Twitter,使用Python,我将插入MySQL数据库的推文流化。 在这里,date列具有datetime类型。 使用这些库: from tweepy import Stream from tweepy import OAuthHandler from tweepy.streaming import StreamListener import MySQLdb import time import json 这个班呢 class listener(StreamListener):
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
import MySQLdb
import time
import json
这个班呢
class listener(StreamListener):
def on_data(self, data):
all_data = json.loads(data)
tweet = all_data["text"]
ID_Tweet = all_data["id_str"]
c.execute("INSERT INTO tweets (t_date, user_name, tweet, ID_Tweet) VALUES (%s,%s, %s,%s)",
(time.localtime(), username, tweet, ID_Tweet))
....
我总是收到这样的警告:
警告(来自警告模块):文件
“C:\Users\OB\Desktop\TwT\connect.py”,第35行
(time.time(),username,tweet,ID_tweet))警告:第1行“t_date”列的数据被截断
当我检查数据库时,会插入推文,但带有此时间值0000-00-00:00:00