65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import pymysql
|
|
from sshtunnel import SSHTunnelForwarder
|
|
from pymysql.converters import escape_string
|
|
from ruamel.yaml import YAML
|
|
import math
|
|
|
|
# ===================config===================
|
|
|
|
server = SSHTunnelForwarder(
|
|
ssh_address_or_host=("47.254.83.25", 22),
|
|
ssh_username="root",
|
|
ssh_password="ByWayStudios01!",
|
|
remote_bind_address=("127.0.0.1",3306),
|
|
local_bind_address=('127.0.0.1',5143)
|
|
)
|
|
server.start()
|
|
db_host = server.local_bind_host
|
|
db_port = server.local_bind_port
|
|
|
|
conn = pymysql.connect(
|
|
host=db_host,
|
|
port=db_port,
|
|
user="root",
|
|
password="Xijing1!",
|
|
database="Merge_Pet_1"
|
|
)
|
|
cursor = conn.cursor()
|
|
|
|
# 查询所有记录
|
|
cursor.execute("select * from t_player_charge where PayStatus >= 3")
|
|
results = cursor.fetchall()
|
|
|
|
|
|
server2 = SSHTunnelForwarder(
|
|
ssh_address_or_host=("8.155.14.94", 22),
|
|
ssh_username="root",
|
|
ssh_password="-xLX]p!PQ1@SHm`A",
|
|
remote_bind_address=("rm-f8zd2030feam53n43.mysql.rds.aliyuncs.com",3306),
|
|
local_bind_address=('127.0.0.1',5144)
|
|
)
|
|
server2.start()
|
|
db_host2 = server2.local_bind_host
|
|
db_port2 = server2.local_bind_port
|
|
|
|
conn2 = pymysql.connect(
|
|
host=db_host2,
|
|
port=db_port2,
|
|
user="root",
|
|
password="Z4rf7eZZe500dxa",
|
|
database="merge_pet_online"
|
|
)
|
|
cursor2 = conn2.cursor()
|
|
|
|
for row in results:
|
|
Uid = int(row[1]) # 将字符串转换为整数
|
|
cursor2.execute("INSERT INTO log_order (`Uid`, `OrderId`, `Price`, `PayChannelOrderId`, `ProductId`, `CreateTime`, `PayTime`, `PayType`, `Param`, `Timestamp`, `AppId`, `ServerId`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, '', 0, 0, 1)",
|
|
(Uid, row[2], row[6], row[14], row[3], row[8], row[9], row[10]))
|
|
print(row)
|
|
# 提交更改
|
|
conn2.commit()
|
|
cursor.close()
|
|
cursor2.close()
|
|
conn2.close()
|
|
conn.close()
|