MDB API

Note: This is very early documentation on the MDB API -- JMC

Created: November 18, 1999; Updated: December 20, 1999:
The script mdb_sql.php3 can be called by another script or application to perform a search on the MDB, and will return the results as an HTML table, CSV data or as a WDDX packet.

The URL for the script is: http://metallo.scripps.edu/api/mdb_sql.php3, and requires 2 parameters: "query" and "format", the former is the "SELECT" SQL query statement, and the latter indicates the format ("table", "csv" or "wddx"). You can send the parameters using a GET or POST method.

If you call the URL w/o passing any parameter, then the script will output:

ERROR: wrong number of parameters
Parameters:
        query : 'select' query statement
        format : table, csv or wddx
                table = generates an HTML table
                csv = comma separated values (quote: ", escape char: \)
                wddx = a WDDX packet

You can use the following form to experiment by sending a valid SELECT SQL query to the MDB. This script is designed to be used by other scripts or applications, this form interface is for demonstration purposes only.

SQL query:
Output format:


Note: You will see the CSV and WDDX output better by looking at the page source in your browser.

For example, if you use as a query statement: "SELECT source_id,dep_date FROM protein LIMIT 10", and pick "csv" as output format:

title : Metalloprotein-site Structure and Design (SQL query API)
query : select source_id,dep_date from protein limit 10
timestamp : 1999-11-18 23:08:01
number_of_rows : 10
fields_list : source_id,dep_date
"101d","1994-12-14"
"101m","1997-12-13"
"102l","1992-09-29"
"102m","1997-12-15"
"103l","1992-09-29"
"103m","1997-12-16"
"104m","1997-12-18"
"105m","1997-12-18"
"106m","1997-12-21"
"107l","1992-12-17"
and, if you selected "table" as format:

title: Metalloprotein-site Structure and Design (SQL query API)
query: select source_id,dep_date from protein limit 10
timestamp: 1999-11-18 23:10:28
number_of_rows: 10
source_id dep_date
101d 1994-12-14
101m 1997-12-13
102l 1992-09-29
102m 1997-12-15
103l 1992-09-29
103m 1997-12-16
104m 1997-12-18
105m 1997-12-18
106m 1997-12-21
107l 1992-12-17

finally, if you picked "wddx" instead, then the result will be:
<wddxPacket version='0.9'>
  <header comment='SQL query results - MDB' />
  <data>
    <struct>
      <var name='title'>
        <string>
          Metalloprotein-site Structure and Design (SQL query
          API)
        </string>
      </var>
      <var name='query'>
        <string>
          select source_id,dep_date from protein limit 10
        </string>
      </var>
      <var name='timestamp'>
        <string>
          1999-11-18 23:48:12
        </string>
      </var>
      <var name='number_of_rows'>
        <number>
          10
        </number>
      </var>
      <var name='fields_list'>
        <string>
          source_id,dep_date
        </string>
      </var>
      <var name='result_set'>
        <array length='10'>
          <struct>
            <var name='source_id'>
              <string>
                101d
              </string>
            </var>
            <var name='dep_date'>
              <string>
                1994-12-14
              </string>
            </var>
          </struct>
          <struct>
            <var name='source_id'>
              <string>
                101m
              </string>
            </var>
            <var name='dep_date'>
              <string>
                1997-12-13
              </string>
            </var>
          </struct>
          <struct>
            <var name='source_id'>
              <string>
                102l
              </string>
            </var>
            <var name='dep_date'>
              <string>
                1992-09-29
              </string>
            </var>
          </struct>
          <struct>
            <var name='source_id'>
              <string>
                102m
              </string>
            </var>
            <var name='dep_date'>
              <string>
                1997-12-15
              </string>
            </var>
          </struct>
          <struct>
            <var name='source_id'>
              <string>
                103l
              </string>
              &lt;
              /var&gt;
              <var name='dep_date'>
                <string>
                  1992-09-29
                </string>
              </var>
              <struct>
                <var name='source_id'>
                  <string>
                    103m
                  </string>
                </var>
                <var name='dep_date'>
                  <string>
                    1997-12-16
                  </string>
                </var>
              </struct>
              <struct>
                <var name='source_id'>
                  <string>
                    104m
                  </string>
                </var>
                <var name='dep_date'>
                  <string>
                    1997-12-18
                  </string>
                </var>
              </struct>
              <struct>
                <var name='source_id'>
                  <string>
                    105m
                  </string>
                </var>
                <var name='dep_date'>
                  <string>
                    1997-12-18
                  </string>
                </var>
              </struct>
              <struct>
                <var name='source_id'>
                  <string>
                    106m
                  </string>
                </var>
                <var name='dep_date'>
                  <string>
                    1997-12-21
                  </string>
                </var>
              </struct>
              <struct>
                <var name='source_id'>
                  <string>
                    107l
                  </string>
                </var>
                <var name='dep_date'>
                  <string>
                    1992-12-17
                  </string>
                </var>
              </struct>
            </var>
          </struct>
        </array>
      </var>
    </struct>
  </data>
</wddxPacket>