Monday, 30 January 2017

oracle dbms - Python script: Access data from databases



I need to access data that is inside an Oracle database using a Python script. It's a Unix server running oracle 10g. I don't have much access to the database server.


It works fine on model builder when the connection is open and I add my data, but exporting it to Python means all the connection properties are gone (they are just "TABLE NAME" etc.)


Basically the script grabs this information based on a query, let's say "SELECT id WHERE Status = 0", and it writes it to a new table in a filegeodatabase. I need to do it through python as I am processing it further, but that's not my issue.


I just can't get it to connect. I've tried to use pyodbc plugin using the syntax below:



cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=rtsprod;DATABASE=DBNAME;UID=USERID;PWD=PASSWORD')

Now I know it's an Oracle database but can't find any documents on how exactly to connect using the pyodbc plugin. Is there a better way?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...