Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Execute Sql Statement in SQL Server 2008 with ArcSDE connection

$
0
0
hi,
i'm trying to execute this SqlStatement to establish an sql query in sql server 2008 with an arcsde connection (arcsde personel use)

but there is no result.

the sql statement is :

Execute SQL Statement: (SELECT * FROM [TOP10_SIG].[dbo].[ABCBNIVL] WHERE [TOP10_SIG].[dbo].[ABCBNIVL].[TYPECBN] = 3)

an idea please !
I use ArcGIS 10.0
Arcsde personal use

Code:

Code:

import arcpy
from arcpy import env
import sys
import os
arcpy.env.workspace = (r"c:\connectionFiles\conntop10sig.sde")
try:
    SQLStatement = "SELECT * FROM [TOP10_SIG].[dbo].[ABCBNIVL] WHERE [TOP10_SIG].[dbo].[ABCBNIVL].[TYPECBN] = 3 "
    SQLStatementList = SQLStatement.split(";")
    print "\n"
    for sql in SQLStatementList:
        print "Execute SQL Statement: " + sql
        try:
            sdeReturn = sdeConn.execute(sql)
        except Exception, ErrorDesc:
            print "ErrorDesc"
            sdeReturn = False
        if isinstance(sdeReturn, list):
            print "Number of rows returned by query: " + len(sdeReturn), "rows"
            for row in sdeReturn:
                print "row"
                print "\n"
            else:
                if sdeReturn == True:
                    print "SQL statement: " + sql + " ran sucessfully."
                    print "\n"
                else:
                    print "SQL statement: " + sql + " FAILED."
                    print "\n"
except Exception, ErrorDesc:
    print "Exception, ErrorDesc"
except:
    print "Problem executing SQL.


Viewing all articles
Browse latest Browse all 2485

Trending Articles