国产数据库oceanBbase,达梦,金仓与mysql数据库的性能对比 九、python读金仓数据库

#coding=utf-8
import psycopg2
import time
#测试单表插入性能

try:
    start_time = time.time()  # 记录开始时间

    connection1 = conn = psycopg2.connect(host='192.168.0.99', port=54321, user='user', password='pass',  dbname='kingdb')

    # 操作数据库
    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 psycopg2.Error as e:
    print(f'错误:,{e}')

 

posted @ 2024-11-20 13:15  万笑佛  阅读(2)  评论(0编辑  收藏  举报