Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

API to get list of databases for an account?

Discussion in 'cPanel Developers' started by simonpearce, Mar 8, 2009.

  1. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Hi,

    Is there a way to get a list of databases for an account?

    Thanks
     
  2. MattDees

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. MattDees

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Simon,
    Yes, The MysqlFE::listdbs function should work fine for this, it can be called as follows:

    xml-api/cpanel?user=USERNAME&xmlin=%3Ccpanelaction%3E%3Cmodule%3EMysqlFE%3C/module%3E%3Cfunc%3Elistdbs%3C/func%3E%3C/cpanelaction%3E

    or in readable terms

    Code:
    <cpanelaction>
      <module>MysqlFE</module>
      <func>listdbs</func>
    </cpanelaction>
    
    this can be run either from WHM or cpanel. and will return something like:

    Code:
    <cpanelresult>
      <apiversion>2</apiversion>
      <data>
        <db>cptest_testing</db>
        <size>16384</size>
        <sizemeg>0.02</sizemeg>
        <usercount>0</usercount>
      </data>
      <func>listdbs</func>
      <module>MysqlFE</module>
    </cpanelresult>
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Brilliant - thanks Matt!
     
  5. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Ah - am I right in thinking this can only be called from within cPanel?

    I need to be able to grab the list remotely?

    Cheers

    Simon
     
  6. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Thanks Matt - got it.

    Cheers

    (think one of our clocks is out a bit - threads is a bit mixed up!)
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,216
    Likes Received:
    10
    Trophy Points:
    313
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can call this remotely via the XML API :).
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice