max_process =
16
#最大进程数
def
read_SQL_write
(r_host,r_port,r_user,r_passwd,r_db,r_charset,w_host,w_port,w_user,w_passwd,w_db,w_charset,cmd,index
=
None
)
:
#得到tem字典保存着信息
try
: conn
=
pymysql.Connect(host
=
r_host, port
=
r_port, user
=
r_user, passwd
=
r_passwd, db
=
r_db, charset
=
r_charset) cursor
=
conn.cursor() cursor.execute(cmd)
except
Exception
as
e: error
=
"[-][-]
%d
fail to connect SQL for reading"
%
index log_error(
'error.log'
,error)
return
else
: tem
=
cursor.fetchone()
print
(
'[+][+]
%d
succeed to connect SQL for reading'
%
index)
finally
: cursor.close() conn.close()
try
: conn
=
pymysql.Connect(host
数据库并行读取和写入(Python实现)
最新推荐文章于 2021-03-01 07:01:56 发布