Skip to main content
naming
Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

Export the results of arcpy.ArcSDESQLExecute(egdb) to a dbfDBF or csvCSV file

naming
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

How can I export Export the results of arcpy.ArcSDESQLExecute(egdb) to a dbf or csv file?

I was able to meet with one of my coworkers and he walked me through the steps successfully of arcpy.ArcSDESQLExecute(egdb). Now I am trying to export the sqlSQL query results to a dbfDBF or csvCSV file, any recommendations? Below is the script which will list results. Thank you!

import arcpy egdb = r'C:\Users\E149391\Documents\ArcGIS\Projects\ElectricMeterLatLong\esripubp.sde' egdb_conn = arcpy.ArcSDESQLExecute(egdb) sql = ''' select b.servicepointglobalid as Svc_Glbl_ID, b.facilityid, a.addressline1, a.addresscitystate, a.meternumber, a.meterpointnumber, a.premise_num, a.SERVICE_PT_NUM, d.tmsnumber
from refgis.customerdatar a, elepub.electricmeter b, elepub.transformer c, elepub.transformerunit d where a.meterpointnumber = b.meterpointnumber and a.premise_num = b.premisenumber and a.service_pt_num = b.servicepointnumber and b.transformerglobalid = c.globalid and c.facilityid = d.facilityid and a.statusmeter <> 'R' and a.statusmeterrecord = 2 and a.statename = 'MO' ''' egdb_return = egdb_conn.execute(sql) for i in egdb_return: print('{}: {}'.format(*i))

import arcpy
egdb = r'C:\Users\E149391\Documents\ArcGIS\Projects\ElectricMeterLatLong\esripubp.sde' 
egdb_conn = arcpy.ArcSDESQLExecute(egdb) 
sql = ''' select b.servicepointglobalid as Svc_Glbl_ID, b.facilityid, a.addressline1, a.addresscitystate, a.meternumber, a.meterpointnumber, a.premise_num, a.SERVICE_PT_NUM, d.tmsnumber  
from refgis.customerdatar a, elepub.electricmeter b, elepub.transformer c, elepub.transformerunit d 
where a.meterpointnumber = b.meterpointnumber and a.premise_num = b.premisenumber and a.service_pt_num = b.servicepointnumber 
and b.transformerglobalid = c.globalid and c.facilityid = d.facilityid 
and a.statusmeter <> 'R' and a.statusmeterrecord = 2 and a.statename = 'MO' ''' 
egdb_return = egdb_conn.execute(sql)
for i in egdb_return:
   print('{}: {}'.format(*i))

How can I export the results of arcpy.ArcSDESQLExecute(egdb) to a dbf or csv file?

I was able to meet with one of my coworkers and he walked me through the steps successfully of arcpy.ArcSDESQLExecute(egdb). Now I am trying to export the sql query results to a dbf or csv file, any recommendations? Below is the script which will list results. Thank you!

import arcpy egdb = r'C:\Users\E149391\Documents\ArcGIS\Projects\ElectricMeterLatLong\esripubp.sde' egdb_conn = arcpy.ArcSDESQLExecute(egdb) sql = ''' select b.servicepointglobalid as Svc_Glbl_ID, b.facilityid, a.addressline1, a.addresscitystate, a.meternumber, a.meterpointnumber, a.premise_num, a.SERVICE_PT_NUM, d.tmsnumber
from refgis.customerdatar a, elepub.electricmeter b, elepub.transformer c, elepub.transformerunit d where a.meterpointnumber = b.meterpointnumber and a.premise_num = b.premisenumber and a.service_pt_num = b.servicepointnumber and b.transformerglobalid = c.globalid and c.facilityid = d.facilityid and a.statusmeter <> 'R' and a.statusmeterrecord = 2 and a.statename = 'MO' ''' egdb_return = egdb_conn.execute(sql) for i in egdb_return: print('{}: {}'.format(*i))

Export the results of arcpy.ArcSDESQLExecute(egdb) to a dbf or csv file

I was able to meet with one of my coworkers and he walked me through the steps successfully of arcpy.ArcSDESQLExecute(egdb). Now I am trying to export the SQL query results to a DBF or CSV file, any recommendations? Below is the script which will list results.

import arcpy
egdb = r'C:\Users\E149391\Documents\ArcGIS\Projects\ElectricMeterLatLong\esripubp.sde' 
egdb_conn = arcpy.ArcSDESQLExecute(egdb) 
sql = ''' select b.servicepointglobalid as Svc_Glbl_ID, b.facilityid, a.addressline1, a.addresscitystate, a.meternumber, a.meterpointnumber, a.premise_num, a.SERVICE_PT_NUM, d.tmsnumber  
from refgis.customerdatar a, elepub.electricmeter b, elepub.transformer c, elepub.transformerunit d 
where a.meterpointnumber = b.meterpointnumber and a.premise_num = b.premisenumber and a.service_pt_num = b.servicepointnumber 
and b.transformerglobalid = c.globalid and c.facilityid = d.facilityid 
and a.statusmeter <> 'R' and a.statusmeterrecord = 2 and a.statename = 'MO' ''' 
egdb_return = egdb_conn.execute(sql)
for i in egdb_return:
   print('{}: {}'.format(*i))

Source Link

How can I export the results of arcpy.ArcSDESQLExecute(egdb) to a dbf or csv file?

I was able to meet with one of my coworkers and he walked me through the steps successfully of arcpy.ArcSDESQLExecute(egdb). Now I am trying to export the sql query results to a dbf or csv file, any recommendations? Below is the script which will list results. Thank you!

import arcpy egdb = r'C:\Users\E149391\Documents\ArcGIS\Projects\ElectricMeterLatLong\esripubp.sde' egdb_conn = arcpy.ArcSDESQLExecute(egdb) sql = ''' select b.servicepointglobalid as Svc_Glbl_ID, b.facilityid, a.addressline1, a.addresscitystate, a.meternumber, a.meterpointnumber, a.premise_num, a.SERVICE_PT_NUM, d.tmsnumber
from refgis.customerdatar a, elepub.electricmeter b, elepub.transformer c, elepub.transformerunit d where a.meterpointnumber = b.meterpointnumber and a.premise_num = b.premisenumber and a.service_pt_num = b.servicepointnumber and b.transformerglobalid = c.globalid and c.facilityid = d.facilityid and a.statusmeter <> 'R' and a.statusmeterrecord = 2 and a.statename = 'MO' ''' egdb_return = egdb_conn.execute(sql) for i in egdb_return: print('{}: {}'.format(*i))