파이썬 3.x + mssql
import pymssql
def execute(query):
conn = pymssql.connect(server='{서버IP}', user='{아이디}', password='{패스워드}', database='{db명}', charset='utf8')
cursor = conn.cursor(as_dict=True)
result_data = []
if conn:
# print('{서버IP} connected')
cursor.execute(query)
index = 0
for row in cursor:
result_data.insert(index, row)
index = index + 1
else:
# print('{서버IP} connect error')
pass
conn.close()
conn = None
return result_data
def procedure_text(sp_name):
sql = "SELECT OBJECT_NAME(object_id) AS sp_name, OBJECT_DEFINITION(object_id) AS sp_context FROM sys.procedures WHERE OBJECT_DEFINITION(object_id) like '%" + sp_name + "%'"
result = execute_fa(sql)
if result:
for item in result:
if(item['sp_name'] == sp_name):
sp_context = item['sp_context'].replace(sp_name, "")
# print(sp_name, " - RESULT")
else:
sp_context = "NO_RESULT"
# print(sp_name, " - NO_RESULT")
return sp_context
'Web_Application > python' 카테고리의 다른 글
[python] excel 시트간 데이터 비교 후 서식으로 차이 표시 (0) | 2019.04.16 |
---|---|
[python] json 파일 읽기 (0) | 2019.04.09 |
[python][jellyfish] 문자열 유사도 (jaro distance) (0) | 2019.03.26 |
[python] excel to json (0) | 2019.02.08 |
[python] 배열간 빼기 연산 (0) | 2019.01.22 |