Connect MySQLdb
()
| 164 | |
| 165 | |
| 166 | def ConnectDB(): |
| 167 | "Connect MySQLdb " |
| 168 | connect, cursor = None, None |
| 169 | while True: |
| 170 | try: |
| 171 | connect = MySQLdb.connect( |
| 172 | host=HOST, user=USER, passwd=PASSWD, db=DB, port=PORT, charset='utf8') |
| 173 | cursor = connect.cursor() |
| 174 | break |
| 175 | except MySQLdb.Error, e: |
| 176 | print "Error %d: %s" % (e.args[0], e.args[1]) |
| 177 | time.sleep(60)#防止出现永远循环 |
| 178 | return connect, cursor |
| 179 | |
| 180 | |
| 181 | def Thread_Handle(taskList, Total_TaskNum): |