<?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 to convert a sql query result into a table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328083#M25520</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that. Its should be just as straight forward as you wrote there, but the thing about my sql query is that I have like more than 20 columns from that results. If i will create a table first in the GDB, how can I read the columns and column type of my result and use it in creating the fields dynamically? In the part where we loop through the results of the query, if I have 20 columns, I don't want to write "cursor.insertRow((result[0], result[1], .......result[19])".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Jul 2016 22:45:48 GMT</pubDate>
    <dc:creator>ChrisPedrezuela</dc:creator>
    <dc:date>2016-07-04T22:45:48Z</dc:date>
    <item>
      <title>How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328081#M25518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, im using pypyodbc to connect to sql and perform some joins between several tables. How can I directly convert the results into a stand-alone table within a geodatabase?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Thanos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2016 21:30:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328081#M25518</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2016-07-04T21:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328082#M25519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try create an in memory table&lt;/P&gt;&lt;P&gt;results = arcpy.CreateTable_management("in_memory", "VSResults", template, config_keyword)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then open a cursor for this table&lt;/P&gt;&lt;P&gt;cursor = arcpy.da.InsertCursor(results ,("ITEMID", "NAME", "YTPEN"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop into sql statement &lt;STRONG&gt;result&lt;/STRONG&gt; end insert the sql data into the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for &lt;STRONG&gt;result&lt;/STRONG&gt; in cur: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.insertRow((result[0], result[1], result[2])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this table can be stored on geodatabase or set as output parameter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;feature_set = arcpy.RecordSet()&lt;/P&gt;&lt;P&gt;feature_set.load(results)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;arcpy.SetParameter(4, feature_set)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2016 22:03:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328082#M25519</guid>
      <dc:creator>PanagiotisPapadopoulos</dc:creator>
      <dc:date>2016-07-04T22:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328083#M25520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that. Its should be just as straight forward as you wrote there, but the thing about my sql query is that I have like more than 20 columns from that results. If i will create a table first in the GDB, how can I read the columns and column type of my result and use it in creating the fields dynamically? In the part where we loop through the results of the query, if I have 20 columns, I don't want to write "cursor.insertRow((result[0], result[1], .......result[19])".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2016 22:45:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328083#M25520</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2016-07-04T22:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328084#M25521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Before create the table define a template for this table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;template = "C:/tableschema/Projects/vstamplate.dbf"&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;config_keyword = ""&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Execute CreateTable&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;results = arcpy.CreateTable_management("in_memory", "VSResults", template, config_keyword)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this template can be pre configure with fields you are expecting from the query or try with python create this dbf file based on the SQL query results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2016 07:05:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328084#M25521</guid>
      <dc:creator>PanagiotisPapadopoulos</dc:creator>
      <dc:date>2016-07-05T07:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328085#M25522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for the creation dbf files from python a have no experience but looking into the internet you can see some modules about that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://dbfpy.sourceforge.net/" title="http://dbfpy.sourceforge.net/"&gt;Python modules for accessing .dbf (xBase) files&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2016 07:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328085#M25522</guid>
      <dc:creator>PanagiotisPapadopoulos</dc:creator>
      <dc:date>2016-07-05T07:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328086#M25523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The more specifics you provide, the more specific the feedback others can give.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What type of DMBS are you working with?&amp;nbsp; Is the database you are connecting to with &lt;SPAN style="font-family: courier new,courier;"&gt;pypyodbc&lt;/SPAN&gt; a geodatabase?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you checked out the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-query-layer.htm"&gt;Make Query Layer &lt;/A&gt;and &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-query-table.htm"&gt;Make Table Query &lt;/A&gt;tools? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2016 15:00:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328086#M25523</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-07-05T15:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a sql query result into a table</title>
      <link>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328087#M25524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joshua,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working with SQL Server DB. I actually simplified the requirements of my query and managed to avoid using 20 tables and instead just three. So from there it was manageable to just add the results directly to my sde staging table. I think "Make Query Table" will also do as you've suggested but was quite a bit challenging to setup based on the number of table I was working with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2016 04:27:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-convert-a-sql-query-result-into-a-table/m-p/328087#M25524</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2016-07-07T04:27:03Z</dc:date>
    </item>
  </channel>
</rss>

