python连接Microsoft SQL Server 数据库

python连接Microsoft SQL Server 数据库_第1张图片

 

python代码

'''
Author: tkhywang [email protected]
Date: 2023-08-21 11:22:24
LastEditors: tkhywang [email protected]
LastEditTime: 2023-08-21 11:29:30
FilePath: \PythonProject02\Microsoft SQL Server 数据库.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''

import pymssql as pymssql
# 连接数据库
conn = pymssql.connect('192.168.121.130', 'sa', 'Aa123456789', 'jiradb')
# 执行查询
cur = conn.cursor()
cur.execute("SELECT * FROM t_tidb")
# 获取结果
rows = cur.fetchall()
for row in rows:
    print(row)
# 关闭连接
cur.close()
conn.close()

python连接Microsoft SQL Server 数据库_第2张图片

 

你可能感兴趣的:(数据库,python,microsoft)