R
R
redesupar2021-02-09 11:10:38
MySQL
redesupar, 2021-02-09 11:10:38

Transferring a table from mysql to ms sql using python?

made a connection to two databases that are on different hosts

import pymssql
import pymysql

SERVER = "server"
USER = "USER"
PASSWORD = "PASSWORD"
DATABASE = "DATABASE"

connection = pymssql.connect(server=SERVER, user=USER, password=PASSWORD, database=DATABASE)

cursor = connection.cursor()
cursor.execute("DELETE FROM cashier_receipt_copy1")
connection.commit() 



connection = pymysql.connect(host='host',
                             user='user',
                             password='password',                             
                             db='db',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)
 
cur = connection.cursor()

cur.execute("SELECT * FROM trm_in_users")

for row in cur.fetchall():
    print(row)

connection.close()


The question is how to transfer some data from the trm_in_users table to cashier_receipt_copy1 the

names are still different in mysql: store_id id name role_id
and in ms sql store_id_ukm cashier_id cashier_name cashier_role

It seems the task is simple, but I could not do it

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question