I. Description
Installation of Damon's driver
pip install dmPython==2.5.5
Parameters received there, other databases use %, Damon to use?
II. Source code
#coding=utf-8 import pymysql import dmPython import time import uuid #pip install dmPython==2.5.5 #Test single table insert performance to dream try: start_time = () # Record start time connection1 = (host='192.168.0.100', user='user', password='passwd', database='testdb', charset='gbk', port=3306) #Daemon connection2 = conn = (host='192.168.0.99', port=5237, user='user', password='pass' ) # Operate the database cursor1 = () # Create a cursor # Operate the database cursor2 = () # Create a cursor # Define SQL query statements that use %s as a placeholder for parameters sql = "SELECT ID,NAME,CONTENT,CREATE_TIME FROM DB_TEST_T" for i in range(80): print("------i:",i) # Execute SQL queries (sql) # Get query results rows = () data_to_insert = [] for row in rows: # sql statement to insert data into a data table insert_data_sql = """insert into DB_TEST_T ( ID, NAME, CONTENT, CREATE_TIME ) values ( ?, ?, ?, ? );""" random_uuid = uuid.uuid4() data = (str(random_uuid), row[1], row[2], row[3] ) data_to_insert.append(data) batch_size = 50000 for i in range(0, len(data_to_insert), batch_size): batch = data_to_insert[i:i + batch_size] # Batch insertion (insert_data_sql, batch) () # Submission of transactions end_time = () # Record end time execution_time = end_time - start_time # Calculate execution time print(f"Function execution took {execution_time} seconds") except as e: print(f'incorrect:,{e}')
Full test code to get:
(1) Login-Register:/
(2) Search: Performance Comparison of Domestic Databases oceanBbase, Damon, Jinchang and mysql Database