Notice
Recent Posts
Recent Comments
Link
아미(아름다운미소)
ADO 로 데이터베이스 접근하기 본문
윈도우즈에서, 데이터베이스에 접근하려면 ODBC 대신에 ADO도 사용할 수 있다
(Microsoft ActiveX Data Objects). 다음 코드는 ADO COM 객체를 사용하여
Microsoft SQL 서버 데이터베이스에 접근하여, 테이블을 열람하고 화면에 표시한다.
import win32com.client connexion = win32com.client.gencache.EnsureDispatch('ADODB.Connection') connexion.Open("Provider='SQLOLEDB';Data Source='myserver';Initial Catalog='mydatabase';User ID='mylogin';Password='mypassword';") recordset = connexion.Execute('SELECT clientid, clientName FROM clients')[0] while not recordset.EOF: print 'clientid=',recordset.Fields(0).Value,' client name=',recordset.Fields(1).Value recordset.MoveNext() connexion.Close()
'랭귀지 > python' 카테고리의 다른 글
urllib2 그리고 프록시 (0) | 2017.12.19 |
---|---|
SQLite - 단순하게 만든 데이터베이스 (0) | 2017.12.19 |
ODBC로 데이터베이스 접근하기 (0) | 2017.12.17 |
파이썬으로 Microsoft SQL 서버 스크립트하기 (0) | 2017.12.17 |
[python]디렉토리의 내용을 나열하기 (0) | 2017.12.16 |
Comments