BorisHou
6/11/2018 - 2:38 AM

python操作数据库

#coding:utf-8

"""
@project: RCCheker
@file: DatabaseController.py
@author: Boris Hou
@time: 2018-05-25 15:43:58
"""

import pymysql

def mysqlSelect(sql_line):
    db = pymysql.connect(host='sh-cdb-gsye4ky5.sql.tencentcdb.com',port=63732,user='root',passwd='WBxOwV7H4!$',db='loan')
    cursor = db.cursor()
    cursor.execute(sql_line)
    data = cursor.fetchone()
    db.close()

if __name__ == '__main__':
    mysqlSelect(sql_line="SELECT left_field from new_rule_formula where rule_id = "+"47;")