python 达梦数据库操作流程
连接数据库 dm.connect( ... )
获取游标 dm_conn.cursor()
编写SQL语句 sql_str
执行SQL语句 dm_cursor.execute()
获取结果列表 dt_breakpoint = dm_cursor.fetchall()
关闭游标 dm_cursor.close()
关闭数据库连接 dm_conn.close()
代码示例
import pandas as pd
import numpy as np
import datetime
import dmPython as dm
user_name = "dameng"
passwd = "admin"
server_name = "LOCALHOST"
server_port = 5236
def query_ustpf_time_breakpoint( wf_no ):
dm_conn = dm.connect( user=user_name, password=passwd, server=server_name, port=server_port )
dm_cursor = dm_conn.cursor()
sql_str = "select MAIN_LF_4H_PROC_TIME from WF_ST_PF_PARA where WINDPLANT_NO=%d;" % ( wf_no )
print( "func(query_ustpf_time_breakpoint):", sql_str )
<