1. pymssql 설치 (https://pypi.org/project/pymssql/)
(BlogVenv) C:\Work\Software\eclipse-jee-2019-12-R-win32-x86_64\workspace\Blog_sqlite>pip install pymssql
Collecting pymssql
Downloading https://files.pythonhosted.org/packages/e3/9e/75b78d890a07e74f6876e1b22456f236887a4189d3e793cc04204ca15a32/pymssql-2.1.4-cp37-cp37m-win32.whl (353kB)
|| 358kB 243kB/s
Installing collected packages: pymssql
Successfully installed pymssql-2.1.4
-------------------------------------------------------------------------------------------------------------------------------------
import pymssql
#conn = pymssql.connect(server="localhost", user="db_id", password="db_password", database="neogeo.pe.kr") #이렇게 해도된다.
conn = pymssql.connect("localhost", "db_id", "db_password", "neogeo.pe.kr", as_dict=True) #as_dict 조건없다면 row[0]... 이런식으로 접근해야 한다.
csr = conn.cursor()
csr.execute("SELECT * FROM NG_MEMBERS")
rows = csr.fetchall()
for row in rows:
print("{} : {}".format(row["mem_id"], row["mem_name"]))
admin : 관리자
csr.close()
conn.close()