Use arcpy to connect to database without connection file Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Accessing ArcObjects from Python?Guidelines for using ArcObjects from PythonCreate ESRI ArcSDE Connection File (.sde) using Python/ArcPy at the ArcView license level?Arcpy does not execute “CopyFeatures_Management” to write a featureclass to an ArcSDE databaseUsing PostgreSQL with ArcGISReplacing layer ArcSDE connectionSwitch between test and production database in ArcMap?PostgreSQL Database Connection IssueUse multiple connections/databases in a query layer?Creating tables on ArcGIS with arcpy?Connect to remote database with arcpyDatabase Connection error: Invalid database nameCan't connect with my PostgreSQL database with ArcGIS

How would a mousetrap for use in space work?

How could we fake a moon landing now?

How much damage would a cupful of neutron star matter do to the Earth?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Should a wizard buy fine inks every time he want to copy spells into his spellbook?

Strange behavior of Object.defineProperty() in JavaScript

What does 丫 mean? 丫是什么意思?

Random body shuffle every night—can we still function?

What do you call the main part of a joke?

Intuitive explanation of the rank-nullity theorem

What's the point of the test set?

What is best way to wire a ceiling receptacle in this situation?

1-probability to calculate two events in a row

Tannaka duality for semisimple groups

Why is it faster to reheat something than it is to cook it?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

How often does castling occur in grandmaster games?

How to compare two different files line by line in unix?

What does this say in Elvish?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

Google .dev domain strangely redirects to https

Time evolution of a Gaussian wave packet, why convert to k-space?

Amount of permutations on an NxNxN Rubik's Cube



Use arcpy to connect to database without connection file



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Accessing ArcObjects from Python?Guidelines for using ArcObjects from PythonCreate ESRI ArcSDE Connection File (.sde) using Python/ArcPy at the ArcView license level?Arcpy does not execute “CopyFeatures_Management” to write a featureclass to an ArcSDE databaseUsing PostgreSQL with ArcGISReplacing layer ArcSDE connectionSwitch between test and production database in ArcMap?PostgreSQL Database Connection IssueUse multiple connections/databases in a query layer?Creating tables on ArcGIS with arcpy?Connect to remote database with arcpyDatabase Connection error: Invalid database nameCan't connect with my PostgreSQL database with ArcGIS



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















It seems like arcpy can only work with connection files. This creates one of two problems:



  1. Deployment requires manual creation of connection files.

  2. We have to write a bunch of code to recreate the connection file on each run. (Creating it only the first time is not feasible since the connection information may change.)

As a software developer who does not have access to the production environment, I want to minimize manual steps in the deployment, and I want to keep my code simple. I also want this information to be very easy to change and not require opening up ArcMap (which would be manual), so I want to store it in a simple text config file and establish connections on the fly in my script.



Is there a way to create a connection to a database without creating a connection file? An "in memory only" connection (like is possible with pretty much any other database technology, even Oracle, or a number of other libraries, like GDAL)?



I'm using ArcGIS 10.2, and I will only be establishing query layers.










share|improve this question
























  • As @Luke noted in comment to an answer, it's possible from Arcobjects. He has an example here: code.google.com/p/metageta/source/browse/tools/…

    – matt wilkie
    Jan 8 '15 at 17:55

















4















It seems like arcpy can only work with connection files. This creates one of two problems:



  1. Deployment requires manual creation of connection files.

  2. We have to write a bunch of code to recreate the connection file on each run. (Creating it only the first time is not feasible since the connection information may change.)

As a software developer who does not have access to the production environment, I want to minimize manual steps in the deployment, and I want to keep my code simple. I also want this information to be very easy to change and not require opening up ArcMap (which would be manual), so I want to store it in a simple text config file and establish connections on the fly in my script.



Is there a way to create a connection to a database without creating a connection file? An "in memory only" connection (like is possible with pretty much any other database technology, even Oracle, or a number of other libraries, like GDAL)?



I'm using ArcGIS 10.2, and I will only be establishing query layers.










share|improve this question
























  • As @Luke noted in comment to an answer, it's possible from Arcobjects. He has an example here: code.google.com/p/metageta/source/browse/tools/…

    – matt wilkie
    Jan 8 '15 at 17:55













4












4








4


2






It seems like arcpy can only work with connection files. This creates one of two problems:



  1. Deployment requires manual creation of connection files.

  2. We have to write a bunch of code to recreate the connection file on each run. (Creating it only the first time is not feasible since the connection information may change.)

As a software developer who does not have access to the production environment, I want to minimize manual steps in the deployment, and I want to keep my code simple. I also want this information to be very easy to change and not require opening up ArcMap (which would be manual), so I want to store it in a simple text config file and establish connections on the fly in my script.



Is there a way to create a connection to a database without creating a connection file? An "in memory only" connection (like is possible with pretty much any other database technology, even Oracle, or a number of other libraries, like GDAL)?



I'm using ArcGIS 10.2, and I will only be establishing query layers.










share|improve this question
















It seems like arcpy can only work with connection files. This creates one of two problems:



  1. Deployment requires manual creation of connection files.

  2. We have to write a bunch of code to recreate the connection file on each run. (Creating it only the first time is not feasible since the connection information may change.)

As a software developer who does not have access to the production environment, I want to minimize manual steps in the deployment, and I want to keep my code simple. I also want this information to be very easy to change and not require opening up ArcMap (which would be manual), so I want to store it in a simple text config file and establish connections on the fly in my script.



Is there a way to create a connection to a database without creating a connection file? An "in memory only" connection (like is possible with pretty much any other database technology, even Oracle, or a number of other libraries, like GDAL)?



I'm using ArcGIS 10.2, and I will only be establishing query layers.







arcgis-desktop arcpy arcgis-10.2 query-layer connection






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 21 '15 at 10:27









PolyGeo

54k1782246




54k1782246










asked Feb 10 '14 at 11:08









jpmc26jpmc26

998723




998723












  • As @Luke noted in comment to an answer, it's possible from Arcobjects. He has an example here: code.google.com/p/metageta/source/browse/tools/…

    – matt wilkie
    Jan 8 '15 at 17:55

















  • As @Luke noted in comment to an answer, it's possible from Arcobjects. He has an example here: code.google.com/p/metageta/source/browse/tools/…

    – matt wilkie
    Jan 8 '15 at 17:55
















As @Luke noted in comment to an answer, it's possible from Arcobjects. He has an example here: code.google.com/p/metageta/source/browse/tools/…

– matt wilkie
Jan 8 '15 at 17:55





As @Luke noted in comment to an answer, it's possible from Arcobjects. He has an example here: code.google.com/p/metageta/source/browse/tools/…

– matt wilkie
Jan 8 '15 at 17:55










2 Answers
2






active

oldest

votes


















6














You could create temporary connection files through a combination of the tempfile module in the Python standard library and the Create Database Connection Geoprocessing tool.



Your config file could be read in your script, used to make a temporary connection file, establish your Query Layers, and then delete the connection file.






share|improve this answer


















  • 1





    I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

    – jpmc26
    Feb 11 '14 at 0:35







  • 1





    Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

    – user2856
    Feb 11 '14 at 0:38











  • It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

    – jpmc26
    Feb 11 '14 at 20:44


















-1














Yeah there is. Just use the name found in Database properties. As long as each user follows a naming convention when naming their connections you should be fine.



I use the getpass module to help with putting the right username in that string.



Open the properties tab on your geodatabase in arcmap, it should be the last one just labeled "properties". In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username to build that name. Then you would have that same connection file for every user who runs your script, assuming that they've all named their connections the same way.



This essentially allows you to use the connection files you already have in arcmap. It should work similarly for arcpro.






share|improve this answer

























  • I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

    – jpmc26
    Apr 12 at 0:54












  • @jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

    – Steve
    Apr 12 at 13:55











  • @jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

    – Steve
    Apr 12 at 13:56











  • @jpmc26 sorry, it's actually in properties, not connection properties.

    – Steve
    Apr 12 at 14:01











  • The code in question runs on a server. It is not invoked by humans.

    – jpmc26
    Apr 12 at 21:14











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f86007%2fuse-arcpy-to-connect-to-database-without-connection-file%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














You could create temporary connection files through a combination of the tempfile module in the Python standard library and the Create Database Connection Geoprocessing tool.



Your config file could be read in your script, used to make a temporary connection file, establish your Query Layers, and then delete the connection file.






share|improve this answer


















  • 1





    I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

    – jpmc26
    Feb 11 '14 at 0:35







  • 1





    Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

    – user2856
    Feb 11 '14 at 0:38











  • It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

    – jpmc26
    Feb 11 '14 at 20:44















6














You could create temporary connection files through a combination of the tempfile module in the Python standard library and the Create Database Connection Geoprocessing tool.



Your config file could be read in your script, used to make a temporary connection file, establish your Query Layers, and then delete the connection file.






share|improve this answer


















  • 1





    I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

    – jpmc26
    Feb 11 '14 at 0:35







  • 1





    Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

    – user2856
    Feb 11 '14 at 0:38











  • It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

    – jpmc26
    Feb 11 '14 at 20:44













6












6








6







You could create temporary connection files through a combination of the tempfile module in the Python standard library and the Create Database Connection Geoprocessing tool.



Your config file could be read in your script, used to make a temporary connection file, establish your Query Layers, and then delete the connection file.






share|improve this answer













You could create temporary connection files through a combination of the tempfile module in the Python standard library and the Create Database Connection Geoprocessing tool.



Your config file could be read in your script, used to make a temporary connection file, establish your Query Layers, and then delete the connection file.







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 10 '14 at 23:55









Jason ScheirerJason Scheirer

16.9k24569




16.9k24569







  • 1





    I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

    – jpmc26
    Feb 11 '14 at 0:35







  • 1





    Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

    – user2856
    Feb 11 '14 at 0:38











  • It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

    – jpmc26
    Feb 11 '14 at 20:44












  • 1





    I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

    – jpmc26
    Feb 11 '14 at 0:35







  • 1





    Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

    – user2856
    Feb 11 '14 at 0:38











  • It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

    – jpmc26
    Feb 11 '14 at 20:44







1




1





I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

– jpmc26
Feb 11 '14 at 0:35






I was really hoping to not be tied to the file system at all. That prospect doesn't look very good; does it? one of the reasons I don't like working with ESRI. They make it so hard to develop a clean, simple solution.

– jpmc26
Feb 11 '14 at 0:35





1




1





Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

– user2856
Feb 11 '14 at 0:38





Worth noting that the Create Database Connection tool requires ArcEditor/Standard or ArcInfo/Advanced license levels only and is not available for ArcView/Basic licenses. A workaround is to create the connection using ArcObjects via python and comtypes.

– user2856
Feb 11 '14 at 0:38













It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

– jpmc26
Feb 11 '14 at 20:44





It should be noted that using tempfile to actually create the file may be ill-advised. It does a lot of crazy stuff with permissions and visibility of the file and may obtain a write-lock on the file. That may or may not be a problem; I didn't check. I just used gettempdir() and made my own file in there and am deleting it in a finally block at the end of my program. (I'm also deleting it before creating the connection if it exists, just to be safer.)

– jpmc26
Feb 11 '14 at 20:44













-1














Yeah there is. Just use the name found in Database properties. As long as each user follows a naming convention when naming their connections you should be fine.



I use the getpass module to help with putting the right username in that string.



Open the properties tab on your geodatabase in arcmap, it should be the last one just labeled "properties". In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username to build that name. Then you would have that same connection file for every user who runs your script, assuming that they've all named their connections the same way.



This essentially allows you to use the connection files you already have in arcmap. It should work similarly for arcpro.






share|improve this answer

























  • I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

    – jpmc26
    Apr 12 at 0:54












  • @jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

    – Steve
    Apr 12 at 13:55











  • @jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

    – Steve
    Apr 12 at 13:56











  • @jpmc26 sorry, it's actually in properties, not connection properties.

    – Steve
    Apr 12 at 14:01











  • The code in question runs on a server. It is not invoked by humans.

    – jpmc26
    Apr 12 at 21:14















-1














Yeah there is. Just use the name found in Database properties. As long as each user follows a naming convention when naming their connections you should be fine.



I use the getpass module to help with putting the right username in that string.



Open the properties tab on your geodatabase in arcmap, it should be the last one just labeled "properties". In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username to build that name. Then you would have that same connection file for every user who runs your script, assuming that they've all named their connections the same way.



This essentially allows you to use the connection files you already have in arcmap. It should work similarly for arcpro.






share|improve this answer

























  • I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

    – jpmc26
    Apr 12 at 0:54












  • @jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

    – Steve
    Apr 12 at 13:55











  • @jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

    – Steve
    Apr 12 at 13:56











  • @jpmc26 sorry, it's actually in properties, not connection properties.

    – Steve
    Apr 12 at 14:01











  • The code in question runs on a server. It is not invoked by humans.

    – jpmc26
    Apr 12 at 21:14













-1












-1








-1







Yeah there is. Just use the name found in Database properties. As long as each user follows a naming convention when naming their connections you should be fine.



I use the getpass module to help with putting the right username in that string.



Open the properties tab on your geodatabase in arcmap, it should be the last one just labeled "properties". In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username to build that name. Then you would have that same connection file for every user who runs your script, assuming that they've all named their connections the same way.



This essentially allows you to use the connection files you already have in arcmap. It should work similarly for arcpro.






share|improve this answer















Yeah there is. Just use the name found in Database properties. As long as each user follows a naming convention when naming their connections you should be fine.



I use the getpass module to help with putting the right username in that string.



Open the properties tab on your geodatabase in arcmap, it should be the last one just labeled "properties". In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username to build that name. Then you would have that same connection file for every user who runs your script, assuming that they've all named their connections the same way.



This essentially allows you to use the connection files you already have in arcmap. It should work similarly for arcpro.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 12 at 14:00

























answered Apr 11 at 17:16









SteveSteve

15210




15210












  • I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

    – jpmc26
    Apr 12 at 0:54












  • @jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

    – Steve
    Apr 12 at 13:55











  • @jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

    – Steve
    Apr 12 at 13:56











  • @jpmc26 sorry, it's actually in properties, not connection properties.

    – Steve
    Apr 12 at 14:01











  • The code in question runs on a server. It is not invoked by humans.

    – jpmc26
    Apr 12 at 21:14

















  • I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

    – jpmc26
    Apr 12 at 0:54












  • @jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

    – Steve
    Apr 12 at 13:55











  • @jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

    – Steve
    Apr 12 at 13:56











  • @jpmc26 sorry, it's actually in properties, not connection properties.

    – Steve
    Apr 12 at 14:01











  • The code in question runs on a server. It is not invoked by humans.

    – jpmc26
    Apr 12 at 21:14
















I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

– jpmc26
Apr 12 at 0:54






I don't understand. I was unable to find any information on an ArcGIS API that allowed my script to create a connection without also creating a file of the ArcGIS connection format. In particular, my script would run unattended, with no user input. ArcGIS does not seem to understand any kind of connection other than a file. If you know of some API of that sort, please include it in your answer. (Also please notify me if you do so.)

– jpmc26
Apr 12 at 0:54














@jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

– Steve
Apr 12 at 13:55





@jpmc26, it's not an api. It's pretty close to secret knowledge honestly. Just open up arcmap and go to the connection properties for your enterprise geodatabase. In the general information section there should be a name. Copy that name into your script and use that in place of Database Connections in your feature class and feature dataset strings; that name will be your workspace. If you look at how the name is constructed, you should notice that part of that string is the username used to sign on to that computer. You can use the getpass module in python to get that username for

– Steve
Apr 12 at 13:55













@jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

– Steve
Apr 12 at 13:56





@jpmc26 every single person who runs your code. Then you'll be using the connection file you already have for your maps and there should be no need to create another connection file. You might also be able to just edit the tables in your RDMS directly. If you do that you should be able to get away with using SQalchemy or pyodbc, but I wouldn't recommend that.

– Steve
Apr 12 at 13:56













@jpmc26 sorry, it's actually in properties, not connection properties.

– Steve
Apr 12 at 14:01





@jpmc26 sorry, it's actually in properties, not connection properties.

– Steve
Apr 12 at 14:01













The code in question runs on a server. It is not invoked by humans.

– jpmc26
Apr 12 at 21:14





The code in question runs on a server. It is not invoked by humans.

– jpmc26
Apr 12 at 21:14

















draft saved

draft discarded
















































Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f86007%2fuse-arcpy-to-connect-to-database-without-connection-file%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

QGIS export composer to PDF scale the map [closed] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Print Composer QGIS 2.6, how to export image?QGIS 2.8.1 print composer won't export all OpenCycleMap base layer tilesSave Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?Export QGIS Print Composer PDF with searchable text labelsQGIS Print Composer does not change from landscape to portrait orientation?How can I avoid map size and scale changes in print composer?Fuzzy PDF export in QGIS running on macSierra OSExport the legend into its 100% size using Print ComposerScale-dependent rendering in QGIS PDF output

PDF-ში გადმოწერა სანავიგაციო მენიუproject page