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

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

Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221