#!/usr/bin/env python
# -*- encoding: utf8 -*-
# Author: iamacnhero@http://www.doczj.com/doc/1ee31fd776eeaeaad1f33026.html
# Created: 2009-12-14
from __future__ import division
import MySQLdb, random, datetime, time, os, sys
import ConfigParser
import string, os, sys
# read mysql config file
config_file = "/root/http://www.doczj.com/doc/1ee31fd776eeaeaad1f33026.htmlf" #目前应用/etc/http://www.doczj.com/doc/1ee31fd776eeaeaad1f33026.htmlf文件
if (os.path.exists(config_file)):
cf = ConfigParser.ConfigParser()
cf.read(config_file)
host = cf.get("client", "host")
user = cf.get("client", "user")
password = cf.get("client", "password")
db = ""
else:
host = '192.168.200.225'
user = 'root'
password = 'p0o9i8u7'
db = ''
# today = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
#----------------------------------------------------------------------
def getConn(host, user, passwd, db='jobmd_new', port=3306, charset=''):
try:
conn = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db, port=port, charset=charset)
return conn
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit(1)
#----------------------------------------------------------------------
def closeConn(conn):
"""close mysql connection"""
conn.close()
#----------------------------------------------------------------------
def getValue(conn, query):