Python 单表查询数据

import pymssql #引入pymssql模块



# -----------------------------------------------------
import pymssql #引入pymssql模块


def conn():
connect = pymssql.connect('.', 'sa', 'ok', 'pubs') #服务器名,账户,密码,数据库名
if connect:
print("连接成功!")
cursor = connect.cursor()
cursor.execute('select * from jobs')
result = cursor.fetchall()
print(cursor.rowcount)
for row in result:
print(row)
return connect


if __name__ == '__main__':
conn = conn()








posted @ 2020-11-21 21:47  东方不败之小小超  阅读(7)  评论(0编辑  收藏