import pymssql
def execute(query):
conn = pymssql.connect(server='{{SERVER_IP}}', user='{{USER_ID}}', password='{{PASSWORD}}', database='{{DB_NAME}}', charset='utf8')
cursor = conn.cursor(as_dict=True)
result_data = []
if conn:
cursor.execute(query)
index = 0
for row in cursor:
result_data.insert(index, row)
index = index + 1
else:
pass
conn.close()
conn = None
return result_data
sql = "SELECT * FROM {{TABLE_NAME}} WHERE IDX=1"
result = execute(sql)
print(result)
'Web_Application > python' 카테고리의 다른 글
python md5 사용법 (0) | 2019.06.29 |
---|---|
simple string format (0) | 2019.06.29 |
[python][win10] scrapy install error (0) | 2019.04.23 |
[python][ubuntu] scrapy install error - setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 (0) | 2019.04.23 |
[python] excel 시트간 데이터 비교 후 서식으로 차이 표시 (0) | 2019.04.16 |