Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7650 มุมมอง

I'm trying to use an XMLRPC connection but I don't know which database to connect to. I can log in to the system, but it doesn't show me which db it is using. How can I find out?

import xmlrpclib

user = 'admin'
password = 'PASSWORD'
host = 'localhost:8069'
db = 'test'  # How do I find out what database to connect to?

sock = xmlrpclib.ServerProxy('http://%s/xmlrpc/common' % host)
uid = sock.login(db, user, password)

อวตาร
ละทิ้ง

HI Kasper, You can select the database by geting in with this URL: www.*YOURDOMAIN*.com/web/database/selector Regards, Juan José - Ing ADHOC

คำตอบที่ดีที่สุด

db_serv_url = 'http://{}/xmlrpc/db'.format(host)

sock = xmlrpclib.ServerProxy(db_serv_url)

dbs = sock.list()

print dbs

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Use your browser to navigate to http://localhost:8069.

You will either see a list of databases in a dropdown in the top right corner, or (if there is only a single database) will need to click the link 'Manage Databases', then 'Drop' to see the name of the database.

อวตาร
ละทิ้ง

Alternatively, look in the URL when you have logged into the system via the web for the db= parameter.

คำตอบที่ดีที่สุด

For python 3.x you can use following

xmlrpc.client.ServerProxy("https://yourdomain.com/xmlrpc/db").list()

อวตาร
ละทิ้ง