CData Python Connector for OData

Build 20.0.7587

Calling Stored Procedures

You can execute stored procedures using either the execute() or callproc() method of the cursor object.

Call Stored Procedures Using the Execute Method

Stored procedures are called by issuing EXECUTE commands. The stored procedures parameters are parameterized, as in the following example:

import cdata.odata as mod
conn = mod.connect("User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;")
cur = conn.cursor()
cmd = "EXECUTE Search Url = ?"
params = ("http://mysite.com/MyOrgroot/XRMServices/2011/OrganizationData.svc/LeadSet", )
cur.execute(cmd, params)
rs = cur.fetchall()
for row in rs:
	print(row)

Call Stored Procedures Using the Callproc Method

Rather than using "execute()", one can also use the callproc() method to execute the procedure. The method takes a procedure name and a list of parameters as its arguments:

import cdata.odata as mod
conn = mod.connect("User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;")
cur = conn.cursor()
params = ("http://mysite.com/MyOrgroot/XRMServices/2011/OrganizationData.svc/LeadSet", )
cur.callproc("Search", params)
rs = cur.fetchall()
for row in rs:
	print(row)

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7587