self_example/TensorFlow_eaxmple/Model_train_test/703Test/703Connect.py

26 lines
528 B
Python

import pyodbc
# 定义连接字符串
conn_str = (
r"DRIVER=IhOLEDB.iHistorian.1;"
r"Persist Security Info=True;"
r"Mode=Read;"
r"server=192.168.9.8;"
r"uid=administrator;"
r"pwd=TES@ihistorian2018;"
)
# 使用pyodbc连接数据库
cnxn = pyodbc.connect(conn_str)
# 执行SQL查询
cursor = cnxn.cursor()
cursor.execute("select * from ihTags where tagname= [HN.DF.DF11.DF11_TC1].AIO.AN_Air_Supply_Pressure")
# 处理结果集
for row in cursor.fetchall():
print(row)
# 关闭连接
cnxn.close()