Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- react
- mybatis
- SSL
- JavaScript
- Sqoop
- GIT
- IntelliJ
- Java
- SQL
- Express
- SPC
- 보조정렬
- table
- R
- MSSQL
- es6
- mapreduce
- hadoop
- Eclipse
- NPM
- vaadin
- xPlatform
- tomcat
- 공정능력
- Python
- Android
- Spring
- window
- plugin
- Kotlin
Archives
- Today
- Total
DBILITY
pymssql을 사용한 SQL Server 접속 테스트 본문
반응형
driver가 필요하니 pymssql install
pip install pymssql
db_test.py
import pymssql
server = "localhost"
user = "사용자"
password = "비밀번호"
database = "대상 데이터베이스명"
try:
conn = pymssql.connect(server=server, user=user, password=password, database=database)
cursor = conn.cursor()
sql = """
SELECT A, B, C, D FROM DUMMY_TABLE
"""
cursor.execute(sql)
rows = cursor.fetchall()
for row in rows:
print(row)
cursor.close()
conn.close()
except Exception as e:
print(f"Error Connecting To SQL Server: {e}")
fetch된 row의 type을 확인해 보니 Tuple이다. 당연한 것인가?. 불변이어야 하니.
반응형
'python' 카테고리의 다른 글
pip를 통한 package install 등.. (0) | 2025.09.23 |
---|---|
python matplot scatter chart , linear regression line exercise (0) | 2021.10.13 |
python pandas dataframe (0) | 2021.10.12 |
python papago translate api example (0) | 2021.10.12 |
python matplot pie chart (0) | 2021.08.30 |
Comments