select 时间转换
select from_unixtime(unix_timestamp(order_time) ,'yyyy-MM-dd') as dd。
DATE_FORMAT(from_unixtime(order_time),'%Y%m%d')。
mysql 连接
mysql -h -P -u -p -D
python mysql
import MySQLdb
reload(sys)
sys.setdefaultencoding('utf8')
conn = MySQLdb.connect(host = 'ip', \
user = 'user', \
passwd = 'passwd', \
db = 'db', \
port = port)
cursor = conn.cursor()
cursor.execute('set names "utf8"');
sql = "select * from name_list limit 10"
cursor.execute(sql)
out_list = cursor.fetchall()
网友评论