Last active
August 29, 2015 14:14
-
-
Save mbiette/8941cb745fda558bd748 to your computer and use it in GitHub Desktop.
Connect to an AS/400 (iSeries) using ADODB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client | |
def main(host, iasp, library, file): | |
conn = win32com.client.Dispatch(r'ADODB.Connection') | |
DSN=('DRIVER=iSeries Access ODBC Driver;SYSTEM='+host+';DATABASE='+iasp+';COMPRESSION=1;TRANSLATE=1;') | |
conn.Open(DSN) # Will prompt for username/password or connect with Kerberos | |
rs = win32com.client.Dispatch(r'ADODB.Recordset') | |
rs.Open("SELECT * FROM "+library+"."+file, conn, 1, 3) | |
# Get records and fields one by one | |
#while not rs.EOF: | |
# for field in rs.Fields: | |
# print(field.Name,field.Value) | |
# rs.MoveNext() | |
# Just get everything | |
data = rs.GetRows() | |
print(data) | |
conn.Close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment