#coding=utf-8 import pymysql import time #測試單表插入效能 try: start_time = time.time() # 記錄開始時間 connection1 = pymysql.connect(host='192.168.0.98', user='user', password='passwd', database='mysqldb',port=3306) # 運算元據庫 cursor1 = connection1.cursor() # 建立一個遊標 # 查詢手機資訊 sql = " select * from DB_TEST_T" # 執行SQL查詢(假設你已經建立了資料庫連線和遊標) cursor1.execute(sql) # 獲取查詢結果 rows = cursor1.fetchall() i = 0 for row in rows: ID = row[0] end_time = time.time() # 記錄結束時間 execution_time = end_time - start_time # 計算執行時間 print(f"Function execution took {execution_time} seconds") except pymysql.Error as e: print(f'錯誤:,{e}')