The AsyncDistributedConnection class represents a distributed SQL connection. It provides the single methods
execute():AsyncDistributedConnection.execute( queries, args)The arguments
queriesandargsare arrays of values. Thequeriesarray contains the SQL statements to be executed while theargsarray contains the parameter values to be inserted into the SQL statement wherever the question mark character "?" appears. For example, the following code snippet prepares twoinsertstatements:nWorkers = 2 q = ["INSERT INTO MyTable(pk, value, u2, i1, i2, i4, i8, flt, dbl) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"] * nWorkers args = [] for i in xrange(nWorkers): args.append((i*100, 'str%s' % i, i, i, i, i, i, i*100, i*100.9))For SQL
insert,updateordeletestatements, the execute() method returns an integer value indicating the number of rows affected. For example, the following code snippet would print out the number of rows inserted by the twoinsertstatements created above:r = conn.execute(q, args) print "len(r)=", len(r) for k in range(len(r)): pprint.pprint(r[k])For SQL
selectstatements (queries), theexecute()method returns result sets. For example, the following code snippet executes four queries (that do not require arguments) then displays their result sets:q = [ "SELECT COUNT(*) FROM MyTable", "SELECT SUM(pk) FROM MyTable", "SELECT SUM(i1) FROM MyTable", "SELECT SUM(i2) FROM MyTable" ] r = conn.execute(q, None) print "len(r)=", len(r) for k in range(len(r)): pprint.pprint(r[k])