-5

If I am use Arcpy how can I get count feature layer and data count in SDE database connection.

closed as off-topic by Midavalo Oct 27 '17 at 13:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – Midavalo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please edit your question to include as much information as you can about what you are trying to do, and what happens when you try it. Include a snippet of your code that shows your attempt, and the output of that attempt (including any error messages). – Midavalo Oct 27 '17 at 13:58
3

If you want to Count features in a feature class / layer then use Get Count:

Returns the total number of rows for a table.

From the help section of the tool:

# Name: fcCount.py
# Purpose: calculate the number of features in a featureclass

# Import system modules
import arcpy

lyrfile = r"C:\data\streets.lyr"
result = arcpy.GetCount_management(lyrfile)
count = int(result.getOutput(0))
print count

If you want to Count the feature classes instead, then:

import arcpy 
arcpy.env.workspace = r"Database Connections\test.sde"
print len(arcpy.ListFeatureClasses())

Not the answer you're looking for? Browse other questions tagged or ask your own question.