【转帖】【笔记】python连接神通数据库

济南小老虎 / 2024-01-09 / 原文

https://

 

python连接国产神州通用数据库。

一、准备

下载whl及dll:

链接: https://pan.baidu.com/s/1lwE-FwIsf-aYjoqCPij2hA 提取码: 49qp

二、安装

 

目录如上。

1、aci.dll 加入环境变量

2、选择python对应版本,使用pip install xxx.whl 安装工具包。

3、python调用工具库读写神通数据库。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
import STPython
 
# 连接器
connection = STPython.Connection(
    user='SYSDBA',
    password='szoscar55',
    dsn='localhost:2003/OSRDB'
)
# 游标
cursor = STPython.Cursor(connection)
 
# 执行SQL
cursor.execute('select * from OFCMS.STUDENT;')
 
for site_account in cursor.fetchall():
    print(site_account)
 
# 关闭游标
cursor.close()