您的位置:首页 > 编程语言 > Python开发

Python连接数据库查询

2016-06-29 09:48 567 查看
<pre name="code" class="python"># set default encoding to utf-8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8")

from util.db import db
from util.logger import logger
from sqlalchemy import text

if __name__ == '__main__':
q = text("""
select * from test where id in ( :param )
""")
param1_value = []

rows = db.harbor.execute(q, {'param': "27"}).fetchall()
if rows is not None and len(rows) > 0:
logger.debug("--------%s" % len(rows))
else:
logger.debug("========>>>None")



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: