<?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: how do I read a table that is in a geodatabase in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743075#M57435</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi there.&amp;nbsp; I'm learning from this thread.&amp;nbsp; I'm understanding that the where clause is an SQL line, correct?&amp;nbsp; If that's the case and you need to provide a quoted expression as a parameter, and if a variable representing that expression is not quated, then you could use the... &lt;BR /&gt;repr() function with the variable as an argument to return extra quotes into the parameter as follows..&lt;BR /&gt;Thanks for posting your tests.&amp;nbsp; Let me know if you have any insight on what I'm figuring...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The where clause is only a partial sql statement and while that does work and I got my answer regarding why my where clause didn't work, thanks everyone.&amp;nbsp;&amp;nbsp; I asked if anyone knew how to use python with a full sql statement.&amp;nbsp; I'm not sure in you code what are asking with anystatemt.&amp;nbsp; For the whereclause in sql is typically fieldname = value.&amp;nbsp; You will need to put the value in quotes if it is a string, but not if it is a number; I'm not sure how to encase a date in python.&amp;nbsp; If your value is a variable you need to build the whereclause by concatenating field and value.&amp;nbsp; In my case I had two variables to build my where clause.&amp;nbsp; One was for the name of the field, the other was the value of the data to be selected.&amp;nbsp; In my case the data value was of string type so I had to encased it with quotes the value was '01001'&amp;nbsp; The results I showed was after building the where clause, but it didn't work because I also encased the field name in quotes.&amp;nbsp; I did that because I that's how the field calculator does it.&amp;nbsp; I also tried encasing it in ! bangs, but that didn't work either.&amp;nbsp; I read somewhere that python required field names be encased in the ! symbol, but I guess that's only in the field calculator.&amp;nbsp; If someone has any comments on when the field name should be enclosed in a pair of symbols and what determines which symbol to use I would really like to know.&amp;nbsp; I've seen it with single and double quotes, bangs, and brackets.&amp;nbsp; What is the determination on when to use what?&amp;nbsp; Also, for future reference, in python strings can be denoted with either single or double quotes, numbers are not wrapped with anything, but what about dates.&amp;nbsp; In VBA it was a # pound sign, what is it in python?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Apr 2011 05:51:04 GMT</pubDate>
    <dc:creator>TerrySilveus</dc:creator>
    <dc:date>2011-04-09T05:51:04Z</dc:date>
    <item>
      <title>how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743065#M57425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;how do I read a table that is in a geodatabase&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried putting this into a arcpy.SearchCursor but its not working (not a feature class or shapefile).&amp;nbsp; I can't read it with open because it's not a file in that sense.&amp;nbsp; So how do you load a table located in a geodatabase using python code and iterate through the rows to read some value from a specific column?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Apr 2011 22:30:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743065#M57425</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-05T22:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743066#M57426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post the code you are trying? A search cursor should be able to open a table in a GDB.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 14:37:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743066#M57426</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-04-06T14:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743067#M57427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is just for my benefit... I'm trying to teach myself python.&amp;nbsp; I have programming experience with other languages, but not python and not arcpy (or arcgisscripting for that matter)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

#Initialize variables
searchDSParam = None
searchLinkParam = None
searchFieldParam = None
updateDSParam = None
updateLinkParam = None
updateFieldParam = None

#arcGIS toolbox script
#searchDSParam = arcpy.GetParameterAsText(0)
#searchLinkParam = arcpy.GetParameterAsText(1)
#searchFieldParam = arcpy.GetParameterAsText(2)
#updateDSParam = arcpy.GetParameterAsText(3)
#updateLinkParam = arcpy.GetParameterAsText(4)
#updateFieldParam = arcpy.GetParameterAsText(5)

#for testing
searchDSParam = "C:\GIS\VirtualCampus\SpatialStatsModelBuilder\ModelBuilderTutorial\CDCWonderAnalysis.gdb\HeartDiseaseSouth_1999"
searchLinkParam = "CountyCode"
searchFieldParam = "HD_Rate"
updateDSParam = "C:\GIS\VirtualCampus\SpatialStatsModelBuilder\ModelBuilderTutorial\CDCWonderAnalysis.gdb\HD_Rate_1999"
updateLinkParam = "FIPS"
updateFieldParam = "HDrate"

updateTheRow = None
updateTheRows = None
searchTheRow = None
searchTheRows = None
updateTheFields = None
searchTheField = None
searchTheFields = None
fldType = None
fldPrecision = None
fldScale = None
fldLength = None
whereClause = None
linkTypeText = False

#Dictionary to convert return value from field.type to set value using AddField
fieldTypeDictionary = {'SmallInteger': 'SHORT', 'Integer': 'LONG', 'Single': 'FLOAT', 'Double': 'DOUBLE', 'String': 'TEXT', 'Date': 'DATE'}
changed = 0
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #get work done
&amp;nbsp;&amp;nbsp;&amp;nbsp; #add field to update dataset if necessary
&amp;nbsp;&amp;nbsp;&amp;nbsp; #search cursor has data to be applied to update cursor (in searchFieldParam field)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #update cursor has field to be updated (updateFieldParam gets data from searchFieldParam)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #link update cursor with search cursor on fields searchLinkParam/updateLinkParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTheFields = arcpy.ListFields(updateDSParam) #get a list of fields in shapefile to be updated
&amp;nbsp;&amp;nbsp;&amp;nbsp; searchTheFields = arcpy.ListFields(searchDSParam) #get a list of fields in the shapefile to be searched
&amp;nbsp;&amp;nbsp;&amp;nbsp; for searchTheField in searchTheFields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheField.name == searchFieldParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fldType = searchTheField.type
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fldPrecision = searchTheField.precision
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fldScale = searchTheField.scale
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fldLength = searchTheField.length
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheField.name == searchLinkParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheField.type == "String":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linkTypeText = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #check to see if it has the field that will be updated, if it has it good; if not then add the field
&amp;nbsp;&amp;nbsp;&amp;nbsp; #NOT SURE THIS IS WORKING FOR THE CASE WHEN FIELD ALREADY EXISTS - HAVE NOT TESTED YET - BUT IT ADDS FIELD OK (Have been deleting the field for testing)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not updateFieldParam in updateTheFields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #field does not exist - need to add field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(updateDSParam,updateFieldParam,fieldTypeDictionary[fldType], fldPrecision, fldScale, fldLength) #adds field to data set

&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTheRows = arcpy.UpdateCursor(updateDSParam) #get the rows from the shapefile that will have a field updated
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for updateTheRow in updateTheRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #loop through all the rows in the update cursor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if linkTypeText:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "'" + searchLinkParam + "' = '" + updateTheRow.getValue(updateLinkParam) + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "'" + searchLinkParam + "' = " + updateTheRow.getValue(updateLinkParam) 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateTheRow.getValue(updateLinkParam) == "01001":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print updateTheRow.getValue(updateLinkParam)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # THIS SECTION NOT WORKING...SEARCH CURSOR DOESN'T LOAD DATA (EVEN WITHOUT WHERECLAUSE)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; searchTheRows = arcpy.SearchCursor(searchDSParam,whereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for searchTheRow in searchTheRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheRow.getValue(searchFieldParam) &amp;lt;&amp;gt; "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTheRow.setValue(updateFieldParam,searchTheRow.getValue(searchFieldParam))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTheRows.updateRow(updateTheRow)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; changed = changed + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break #exit search cursor loop - you found first row with data and updated row
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; searchTheRows = None
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateTheRows = None
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display exceptions
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not arcpy.GetMessages() == "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessage(2))

finally:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #clean up everything
&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateTheFields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del updateTheFields

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheFields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchTheFields

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheField:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchTheField

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheRow:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchTheRow

&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateTheRow:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del updateTheRow

&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateTheRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del updateTheRows

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchTheRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchTheRows

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchDSParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchDSParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchLinkParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchLinkParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateDSParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del updateDSParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchFieldParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del searchFieldParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateLinkParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del updateLinkParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; if updateFieldParam:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del updateFieldParam

&amp;nbsp;&amp;nbsp;&amp;nbsp; if fldLength:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fldLength

&amp;nbsp;&amp;nbsp;&amp;nbsp; if fldType:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fldType

&amp;nbsp;&amp;nbsp;&amp;nbsp; if fldPrecision:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fldPrecision

&amp;nbsp;&amp;nbsp;&amp;nbsp; if fldScale:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fldScale

&amp;nbsp;&amp;nbsp;&amp;nbsp; if whereClause:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del whereClause

&amp;nbsp;&amp;nbsp;&amp;nbsp; if linkTypeText:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del linkTypeText

&amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldTypeDictionary:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del fieldTypeDictionary&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743067#M57427</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2021-12-12T07:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743068#M57428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So now I'm thinking it is my where clause... even though I'm sure I tested it without the where clause and got the same issue.&amp;nbsp; I decided to test without again, and this time it looks like it did load the search cursor.&amp;nbsp; So, below is what my where clause looks like as it is passes through the update cursor loop on an iteration that I know has a match... So what exactly should be surrounding the field name in the where clause for the search cursor?&amp;nbsp; 'fldName' or "fldName" or !fldName! or [fldName] or something else?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my whereClause&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"'CountyCode' = '01001'"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 21:01:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743068#M57428</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-06T21:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743069#M57429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'd suggest just writing a barebones version to make sure the actual SearchCursor part works and for other readers here to easily make sense of it. Rewriting it will probably help you figure out what went wrong the first time. Also you don't need to delete variables in Python with a few exceptions such as rows and cursors.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 21:36:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743069#M57429</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-04-06T21:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743070#M57430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not totally sure, but I think the where clause switches you to SQL syntax. So, it would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CountryCode = '01001' &amp;lt;- all enclosed in double-quotes in SearchCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;whereClause = "CountryCode = '01001'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That's really just my best guess - I'm learning, too. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 21:43:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743070#M57430</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-04-06T21:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743071#M57431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the advice regarding deleting variables.&amp;nbsp; I will limit that to just deleting the cursor and row variables.&amp;nbsp; However, I'm not sure how much barer this code can be.&amp;nbsp; It's pretty slim as it is.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it creates a field&amp;nbsp;&amp;nbsp; (this part works)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it loads an update cursor (this part works)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it loads a search cursor (this part doesn't work) -when I use a where clause, but it works without the where clause, so there is an issue with my where clause.&amp;nbsp; I now think I just need to know how to wrap the field name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 21:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743071#M57431</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-06T21:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743072#M57432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;on another note... is there any way in python that I can just write an sql statement and use that instead or somehow pass an entire sql statement to the cursor?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 22:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743072#M57432</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-06T22:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743073#M57433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm not totally sure, but I think the where clause switches you to SQL syntax. So, it would be:&lt;BR /&gt;&lt;BR /&gt;CountryCode = '01001' &amp;lt;- all enclosed in double-quotes in SearchCursor&lt;BR /&gt;&lt;BR /&gt;So,&lt;BR /&gt;&lt;BR /&gt;whereClause = "CountryCode = '01001'"&lt;BR /&gt;&lt;BR /&gt;That's really just my best guess - I'm learning, too. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That's it.&amp;nbsp; You apparently don't need to wrap the field name for the where clause.&amp;nbsp; Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2011 22:55:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743073#M57433</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-06T22:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743074#M57434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there.&amp;nbsp; I'm learning from this thread.&amp;nbsp; I'm understanding that the where clause is an SQL line, correct?&amp;nbsp; If that's the case and you need to provide a quoted expression as a parameter, and if a variable representing that expression is not quated, then you could use the... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;repr() function with the variable as an argument to return extra quotes into the parameter as follows..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for posting your tests.&amp;nbsp; Let me know if you have any insight on what I'm figuring...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; 
Python 2.5
IDLE 1.2.1&amp;nbsp; 
&amp;gt;&amp;gt;&amp;gt;help(gp.searchcursor)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # gp = arcgisscripting.create(9.3) 
Help on built-in function searchcursor:

searchcursor(...)
&amp;nbsp;&amp;nbsp;&amp;nbsp; searchcursor(&amp;lt;dataset&amp;gt;, {where_clause}, {spatial_reference}, {fields}, {sort_fields}) -&amp;gt; object
&amp;nbsp;&amp;nbsp;&amp;nbsp; Returns a search cursor object against the given table/feature class.

&amp;gt;&amp;gt;&amp;gt; a = "anyStatement = '01001'"
&amp;gt;&amp;gt;&amp;gt; a
"anyStatement = '01001'"
&amp;gt;&amp;gt;&amp;gt; print a
anyStatement = '01001'
&amp;gt;&amp;gt;&amp;gt; print repr(a)
"anyStatement = '01001'"
&amp;gt;&amp;gt;&amp;gt; 


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:37:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743074#M57434</guid>
      <dc:creator>MarkWiygul</dc:creator>
      <dc:date>2021-12-12T07:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743075#M57435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi there.&amp;nbsp; I'm learning from this thread.&amp;nbsp; I'm understanding that the where clause is an SQL line, correct?&amp;nbsp; If that's the case and you need to provide a quoted expression as a parameter, and if a variable representing that expression is not quated, then you could use the... &lt;BR /&gt;repr() function with the variable as an argument to return extra quotes into the parameter as follows..&lt;BR /&gt;Thanks for posting your tests.&amp;nbsp; Let me know if you have any insight on what I'm figuring...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The where clause is only a partial sql statement and while that does work and I got my answer regarding why my where clause didn't work, thanks everyone.&amp;nbsp;&amp;nbsp; I asked if anyone knew how to use python with a full sql statement.&amp;nbsp; I'm not sure in you code what are asking with anystatemt.&amp;nbsp; For the whereclause in sql is typically fieldname = value.&amp;nbsp; You will need to put the value in quotes if it is a string, but not if it is a number; I'm not sure how to encase a date in python.&amp;nbsp; If your value is a variable you need to build the whereclause by concatenating field and value.&amp;nbsp; In my case I had two variables to build my where clause.&amp;nbsp; One was for the name of the field, the other was the value of the data to be selected.&amp;nbsp; In my case the data value was of string type so I had to encased it with quotes the value was '01001'&amp;nbsp; The results I showed was after building the where clause, but it didn't work because I also encased the field name in quotes.&amp;nbsp; I did that because I that's how the field calculator does it.&amp;nbsp; I also tried encasing it in ! bangs, but that didn't work either.&amp;nbsp; I read somewhere that python required field names be encased in the ! symbol, but I guess that's only in the field calculator.&amp;nbsp; If someone has any comments on when the field name should be enclosed in a pair of symbols and what determines which symbol to use I would really like to know.&amp;nbsp; I've seen it with single and double quotes, bangs, and brackets.&amp;nbsp; What is the determination on when to use what?&amp;nbsp; Also, for future reference, in python strings can be denoted with either single or double quotes, numbers are not wrapped with anything, but what about dates.&amp;nbsp; In VBA it was a # pound sign, what is it in python?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Apr 2011 05:51:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743075#M57435</guid>
      <dc:creator>TerrySilveus</dc:creator>
      <dc:date>2011-04-09T05:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: how do I read a table that is in a geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743076#M57436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a cursor I use to find dates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
fc = # Feature Class with date field
field = "DateField"
rows = arcpy.SearchCursor(fc, field+" = date '2011-02-22'")
...&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using times I think would be something like. I haven't had the opportunity to test this though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.SearchCursor(fc, field+" = date '2011-02-22 00:00:00'")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For HH:MM:SS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In terms of when to use what brackets etc, this link has some good info on syntax using different data types.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:37:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-read-a-table-that-is-in-a-geodatabase/m-p/743076#M57436</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T07:37:17Z</dc:date>
    </item>
  </channel>
</rss>

