码迷,mamicode.com
首页 > 数据库 > 详细

基于py3和pymysql查询某时间段的数据

时间:2016-04-03 00:16:27      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:

#python3
#xiaodeng
#基于py3和pymysql查询某时间段的数据


import pymysql
conn=pymysql.connect(user=root,passwd=root,host=localhost,db=test.db)
cur=conn.cursor()


‘‘‘【核心语句】‘‘‘
cur.execute("select grage from 表名 where 时间字段 between ‘开始时间‘ and ‘结束时间‘")
#eg:
#select grage from 表名 where 时间字段 between ‘2010-7-12 11:18:54‘ and ‘2010-7-12 11:22:20‘


#用data接收需要返回的数据
data=cur.fethall()


#数据提取工作
for name,age in data:
    print(name,age)
    
conn.close()
cur.close()

 

基于py3和pymysql查询某时间段的数据

标签:

原文地址:http://www.cnblogs.com/dengyg200891/p/5348512.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!