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
- mapreduce
- MSSQL
- JavaScript
- react
- es6
- Eclipse
- SSL
- mybatis
- SPC
- xPlatform
- vaadin
- Spring
- 보조정렬
- window
- R
- Kotlin
- Python
- Sqoop
- NPM
- Express
- 공정능력
- Java
- hadoop
- IntelliJ
- plugin
- tomcat
- SQL
- GIT
- table
- Android
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' 카테고리의 다른 글
| python opencv 기초 학습 정리 (0) | 2026.05.20 |
|---|---|
| fastapi framework 기본 실습 (0) | 2026.05.13 |
| 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 |
Comments