Select to view content in your preferred language

Using Pyhon to connect to a versioned SDE datasoure running on SQL Server

544
1
05-25-2010 10:15 AM
BobJohnson
New Contributor
Hi,

I've written some Python scripts that I can use to connect to SQL Server Express on my local machine.  My plan was to develop the scripts there and then to point the scripts to our geodatabase on a SQL Server instance on a remote server. 

The scripts are working, now I'm having a hard time getting them to connect to the remote database server.  Given the following parameters, what would the connection string look like that I would use in a gp.updatecursor(FeatureClass, WhereClause) look like?

Server:  qServerS5
Service: 9901
Database: DBig
Username: Clyde
Password: password
Transactional Version: DBO.BobsTestVersion

Thanks in advance for your help.

Bob J
0 Kudos
1 Reply
KenHartling
Esri Contributor
Hi Bob,

The first parameter is just the path to your feature class.  The path to an ArcSDE feature class in GP must be done through a .sde file with the appropriate connection info contained within it in order to specify the feature class.  For example:

fc = r'c:\temp\connectionToArcSDE.sde\fcname'
whereClause = "<whateverUwant>"
gp.updatecursor(fc, whereClause)

If you don't already have a .sde file and want to create it on the fly in your script you can use the GP tool CreateArcSDEConnectionFile() (New at 10) to create it.

Ken
0 Kudos