Creating/updating/deleting records using XML-RPC
In the previous recipe, we saw how to search and read data through RPC. In this recipe, we will perform the remaining CRUD operations through RPC, which are create, update (write), and delete (unlink).
Getting ready
We will create the Python program to create
, write
, and unlink
data in the hostel.room
model. Make sure you have installed the my_hostel
module and that the server is running on http://localhost:8017
.
How to do it...
Perform the following steps to create, write, and update a room’s information through RPC:
- Add the
rooms_operation.py
file. You can place this file anywhere you want because the RPC program will work independently. - Add the following code to the
rooms_operation.py
file:from xmlrpc import client server_url = 'http://localhost:8017' db_name = 'cookbook_17e' username = 'admin' password = 'admin' common = client.ServerProxy('%s/xmlrpc/2/common...