
Remote Access
self.cancelTimer("idle")
self.destroyReferences() return 0
Using the "netrpc" module to access the service, a client might be coded as follows. In this case a separate cursor is created in relation to the queries made about each table in the database.
import netrpc
url = "http://localhost:8000/database" service = netrpc.RemoteService(url)
tables = service.execute("show tables")
timout = 30
for entry in tables:
table = entry[0]
print "table: " + table name = service.cursor(30)
print "cursor: " + url + "/" + name
cursor = netrpc.RemoteService(url+"/"+name) cursor.execute("select * from "+table) desc = cursor.description()
print "desc: " + str(desc) data = cursor.fetchall() print "data: " + str(data) cursor.close()
In general, giving open access to a database in this way may not be advisable, especially over the In- ternet. Such a mechanism might be restricted to a corporate intranet. Alternatively, custom interfaces should be layered on top of the database providing interfaces based on functional requirements.
The XML-RPC Gateway
If the Python
import netsvc
import netsvc.xmlrpc
dispatcher = netsvc.Dispatcher() dispatcher.monitor(signal.SIGINT)
validator = Validator()