<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Prompting User to Log in to Database in Python Addin in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637302#M49616</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like that approach, much simpler... better than my next suggestion of putting a checkbox confirming the user had checked over their shoulder &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Oct 2016 23:16:03 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-10-26T23:16:03Z</dc:date>
    <item>
      <title>Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637299#M49613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have built a python addin where a user selects a bunch of polygon features in ArcMap which then queries an Oracle database and provides a spreasheet of the results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works well but the final peice of the puzzle is I need to be able to prompt my users to enter their credentials for the oracle database login so that the script can query the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the record, I am using the python module:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import cx_Oracle&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to connect to the database using the syntax:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class=""&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;db &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt; cx_Oracle&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;connect&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'{0}/{1}@//random.company:1234/db1.company.com'&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;format&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;username&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt; password&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to login. To explain, I am passing the username and password into the connection string via the .format() method. Which ever way I design a login prompt, the script will grab the users credentials and pass them into the connection string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the python addin help documentation, I do not see a function or property anywhere to pop up a dialogue that will accept some sort of textual input. For example, a text box with 2 entry fields. One for the username and one for the password and then a button to accept the credentials. Or some other option that will allow this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Couple answers to questions you may have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q: Why don't you set the environment workspace to the oracle database connection which gives an automatic dialogue to prompt for credential:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;(i.e arcpy.env.workspace = r"Database Connections\oracleDB.sde")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;A: This works fine, however, after logging into the database, I need to query it. Arcpy offers the 'Make Query Layer' tool to build and compile a query in Oracle. After working with this tool for a week or so, it turns out it has a bug which populates incorrect query results (see bug number below). ArcGIS and arcpy do not offer any other option to submit complex queries to Oracle sde connection via python. This is why I choose to use cx_Oracle for this portion of my script. That and it executes much much faster!&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="font-size: 12.0pt;"&gt;BUG-000090452 :&amp;nbsp;The Make Query Layer tool does not respect the Unique fields variable in Model builder, or the oid_fields keyword in Python arcpy.MakeQueryLayer_management() command.&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q: Why don't you use some third party GUI builder like Tkinter?&lt;/P&gt;&lt;P&gt;A: Any use of Tkinter in ArcGIS (Map, Catalogue, etc) will cause it to crash. From what I've read, ArcGIS will not support third party GUI builders. Also, I did test a tkinter widget this and it crashed everytime when using in ArcMap. outside of ArcMap, it worked fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q: Why not just use a combobox as a textual input for a user name and/or password?&lt;/P&gt;&lt;P&gt;A: The problem I have with this is, when the user types into the combobox, I can't mask the characters the user is entering for the password (i.e. when the user types into the box, only asterix appears). I don't want to expose their password to a lurking employee looking over their shoulders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways, what I am looking for is a long shot I think. if anyone can throw an idea or 2 out there, I'm willing to test it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 22:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637299#M49613</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2016-10-26T22:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637300#M49614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;long shot.... since I don't use addins, but harkening back to 'the day' you could control the visible width of a text box or combo box etc but it would accept anything you typed in without truncating characters &amp;nbsp;If you can make it a couple of characters wide, then the lurker would have to really lean in to catch the password&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 22:55:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637300#M49614</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-26T22:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637301#M49615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I chose to use a toolbox script tool so I could create parameter input boxes with ArcToolbox, then the user just selects a database connection that has already been created; no need to enter user/pass every time. I know it's not an add-in but maybe you can convince whomever that a script tool is just as easy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 23:04:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637301#M49615</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2016-10-26T23:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637302#M49616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like that approach, much simpler... better than my next suggestion of putting a checkbox confirming the user had checked over their shoulder &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 23:16:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637302#M49616</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-26T23:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637303#M49617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan, everything is up for grabs at this point. I might play with that, if no other options are available!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 23:18:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637303#M49617</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2016-10-26T23:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637304#M49618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The rub of all of this isn't so much that I am using an addin over a toolbox script, it's that I cannot create complex queries on the oracle database using any existing in arcpy tools, functions or methods. I am forced to use a third party module for this (cx_Oracle) because of the bug I spoke to in my post, so database connections via ArcGIS won't work for my usage case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 23:25:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637304#M49618</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2016-10-26T23:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637305#M49619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you try&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-classes/arcsdesqlexecute.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-classes/arcsdesqlexecute.htm"&gt;arcpy.ArcSDESQLExecute()&lt;/A&gt;&lt;/SPAN&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2016 23:30:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637305#M49619</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2016-10-26T23:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637306#M49620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't suppose that there is anything in the Arcgis PRO conda installation that may be of use&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/07/17/anaconda-spyder-and-arcgis-pro"&gt;/blogs/dan_patterson/2016/07/17/anaconda-spyder-and-arcgis-pro&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or if you do you should be able to add new modules easily if they are within the full stack.... check the 3.4 link in this post&amp;nbsp;&lt;A class="link-titled" href="https://docs.continuum.io/anaconda/pkg-docs" title="https://docs.continuum.io/anaconda/pkg-docs"&gt;Anaconda package list | Continuum Analytics: Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will just simplify patching up a 2.7 version.... you will eventually have to move anyway&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 00:05:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637306#M49620</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-27T00:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637307#M49621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the main need to be able to pass the credentials each time? &amp;nbsp;Although this may seem off subject, read thru this thread &amp;nbsp;&lt;A href="https://community.esri.com/thread/180549"&gt;https://community.esri.com/thread/180549&lt;/A&gt;&amp;nbsp; &amp;nbsp; And think about reading a settings.ini file to grab the credentials and pass it as needed. I'm using this method to give admin rights for my SQL, for my purposes, without prompting or having the user/pass hard coded in the results or other log file. &amp;nbsp;I keep the settings.ini file in a more secure location. &amp;nbsp;I would think you could do something similar for each user with the permissions they need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if that could be a solution or not.....I'm not an oracle person so not sure about security and access, etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 03:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637307#M49621</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-10-27T03:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637308#M49622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blake, I have not tried ArcSDESQLExecute until now. Thanks for pointing that out. I had no idea it existed. So, in testing it basically does the same thing that xc_Oracle does, but is limited in a number of ways. The biggest problem I have is that I can't get the field/column names of the resulting table of the query. In cx_Oracle, you can query the field.column names by looping over the description method of the cursor:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;print [i[0] for i in cursor.description]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;As far as I can tell, after I create the table using ArcSDESQLExecute:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;db_return = db_conn.execute(sql)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;When I loop over the results of the table:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;for items in db_return:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in items:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This will return the data populated by the query, but does not provide field headings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you or anyone else know if this is possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 20:16:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637308#M49622</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2016-10-27T20:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637309#M49623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the iidea, Rebecca. I like this idea and it might work for a personal project I am working on but in this case, I don't have that option. I work for a very large organization with a central IT and security department who's best practice manual indicates that we are not to store username and password information. This also includes exercising any option on a given GUI that allows gives you the option to do so. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 20:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637309#M49623</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2016-10-27T20:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637310#M49624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;Warning...make sure to always check the Results tab to make sure it isn't being stored there, which was my issue. I started looking at the stop/start AGS admin toolbox by &lt;A href="https://community.esri.com/people/khibma-esristaff"&gt;khibma-esristaff&lt;/A&gt;‌ and using that type of dialog, it does store it so you can rerun it. I know he is working on a new version, and maybe he'll address this. &amp;nbsp;??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case it is for getting a token, and I have a static user/pass with limited network privileges and access. I have the settings file on a drive that needs increased priveldges, so only someone with admin rights can run the scripts. Of course nothing is 100% secure, so I understand if you can't work with this, especially if each user needs separate login creds. &amp;nbsp; Maybe if there is a way to tap info the "current user creds" ? &amp;nbsp;I haven't figured it out, but I don't manage our network/domain users. &amp;nbsp;I'm always interested in alternatives too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 20:44:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637310#M49624</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-10-27T20:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637311#M49625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ha, I like your train of thought! You can get the users user name by using the getuser method in the getpass module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;from getpass import getuser&lt;/P&gt;&lt;P&gt;getuser()&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;unfortunately, I'd need a lot of hacking knowledge to get someones password from the system/network in order to automate the connection to oracle.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 21:16:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637311#M49625</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2016-10-27T21:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637312#M49626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;checkbox... did you look over your shoulder? &amp;nbsp; is looking better &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 21:22:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637312#M49626</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-27T21:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637313#M49627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're right, it does not return a formal table object, rather just a list of lists full of the row values. If you know the field names of what you're querying and just want to be able to refer to the fields in your code you could do one of the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Assign the index value of the row list to a variable named as the field name&lt;/LI&gt;&lt;LI&gt;Create a dictionary of dictionaries (edit: some interesting suff &lt;A _jive_internal="true" href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries"&gt;here&lt;/A&gt;)&lt;/LI&gt;&lt;LI&gt;Look into using the &lt;A href="https://docs.python.org/2/library/collections.html#collections.namedtuple"&gt;named tuple&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need an actual table of some kind, you could&amp;nbsp;use GP tools in arcpy to create a table in memory and populate it with your query data, then save it out somewhere. Or, if you're just doing select queries, maybe you can just do a series of &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-table-view.htm"&gt;table views&lt;/A&gt;/&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-feature-layer.htm"&gt;feature layers&lt;/A&gt; with where clauses until you have what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies if I'm just completely missing the mark here because I'm not entirely sure what exactly you're trying to accomplish.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2016 22:09:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637313#M49627</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2016-10-27T22:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637314#M49628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike, something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;from &lt;/SPAN&gt;collections &lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;namedtuple
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

egdb = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;r'path\to\connection.sde'
&lt;/SPAN&gt;egdb_conn = arcpy.ArcSDESQLExecute(egdb)

table = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'SCHEMA.TABLE'
&lt;/SPAN&gt;fields = (&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'SOMEVALUE'&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'SOMENAME'&lt;/SPAN&gt;)

sql = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'SELECT {0} FROM {1}'&lt;/SPAN&gt;.format(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;','&lt;/SPAN&gt;.join(fields), table)

egdb_return = egdb_conn.execute(sql)
row = namedtuple(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'row'&lt;/SPAN&gt;, fields)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;i &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;egdb_return:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;#With a dict
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;i = &lt;SPAN style="color: #000080;"&gt;dict&lt;/SPAN&gt;(&lt;SPAN style="color: #000080;"&gt;zip&lt;/SPAN&gt;(fields,i))
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080;"&gt;print&lt;/SPAN&gt;((i[&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'SOMEVALUE'&lt;/SPAN&gt;], i[&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'SOMENAME'&lt;/SPAN&gt;])
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;#With a named tuple
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;i = row(*i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080;"&gt;print&lt;/SPAN&gt;((i.SOMEVALUE, i.SOMENAME))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:05:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637314#M49628</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-12T03:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Prompting User to Log in to Database in Python Addin</title>
      <link>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637315#M49629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another thought, as mentioned by others by creating a connection file. &amp;nbsp;I have a connection called&lt;/P&gt;&lt;P&gt;"me@myDatabaseName" and it uses domain credentials, not hard coded. &amp;nbsp;That way, I can put it on everyone's machine and it takes their credentials automatically.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/create-arcsde-connection-file.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/create-arcsde-connection-file.htm"&gt;Create ArcSDE Connection File—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;OPERATING_SYSTEM_AUTH —Use Operating system authentication. You do not need to type a user name and password. The connection will be made with the credentials used to log in to the operating system. If the login used for the operating system is not a valid geodatabase login, the connection will fail. Also note you cannot make an ArcSDE service connection using operating system authentication to a geodatabase stored in Oracle, DB2, or Informix.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;.....oops, just noticed it says not Oracle. &amp;nbsp;Oh, well, I'll leave this in case it sparks another idea.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 02:43:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/prompting-user-to-log-in-to-database-in-python/m-p/637315#M49629</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-10-28T02:43:09Z</dc:date>
    </item>
  </channel>
</rss>

