Commit 962072df by larosa

modify func

parent 43ff94b9
Showing with 80 additions and 9 deletions
import json
import mysql.connector
import requests
url = "/sync/Address/updateAddress" # 线上地址需要更改
def main():
def liexin():
db = mysql.connector.connect(
host="master.db2.liexindev.me",
user="liexin_crmv2",
password="liexin_crmv2#zsyM",
database="liexin_crmv2"
host="232.db.liexindev.me",
user="liexin",
password="liexin#zsyM",
database="liexin"
)
cursor = db.cursor()
cursor.execute("select * from lie_company where com_category in (0, 1)")
cursor.execute("select tax_title, business_license from lie_taxinfo")
result = cursor.fetchall()
for row in result:
pass
json_map = {
"company_name_cn": row[0], # tax_title
"business_license": row[1], # business_license
"source_system_id": "", # ?????
"create_uid": "", # ????
"create_name": "", # ?????
"address_data": [
{
"source_id": "tax_id_" ,
"source_code": "",
"address_type": "",
"address": ""
},
{
"source_id": "",
"source_code": "",
"address_type": "",
"address": ""
},
{
"source_id": "",
"source_code": "",
"address_type": "",
"address": ""
}
]
}
#########################################################################
def crm():
db = mysql.connector.connect(
host="master.db2.liexindev.me",
user="liexin_crmv2",
password="liexin_crmv2#zsyM",
database="liexin_crmv2"
)
cursor = db.cursor()
cursor.execute(
"select com_name, business_license_src, creator_id, creator_name, id, com_addr from lie_company where com_category in (0, 1)")
result = cursor.fetchall()
for row in result:
json_map = {
"company_name_cn": row[0], # com_name
"business_license": row[1], # business_license_src
"source_system_id": "3",
"create_uid": str(row[2]), # creator_id
"create_name": row[3], # creator_name
"address_data": [
{
"source_id": "company_" + str(row[4]), # id
"source_code": "", # ???? 为空
"address_type": "", # 这个不确定
"address": row[5] # com_addr
}
]
}
post_data_to_update_address(json_map)
print("-------------------------crm已更新!--------------------------------")
cursor.close()
db.close()
def post_data_to_update_address(data: dict):
response = requests.post(url=url, data=json.dumps(data), headers={"Content-Type": "application/json"})
print("=======" + str(response.status_code) + "======")
if __name__ == '__main__':
main()
\ No newline at end of file
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment