;- Postgres has a much cleaner client API to work with 
;  for REBOL/Command than MySQL. 

REBOL [
    Title: "Postgres Database REBOL/command API"
    Purpose: {
        Exposes the Postgres API in REBOL/command
    }
    Needs: [command]
    File: %postgres.r
]


pq: load/library %libpq.so

routines: [
    PQsetdbLogin [
        "Login to postgres Database"
        pghost [int] pgport [int]
        pgoptions [int] pgtty [int]
        dbName [int] login [string!]
        pwd [string!] return: [long]
    ]

    PQdb           ["Name of database"
                    PGconn [int] return: [string!]]
    PQhost         ["Name of host"
                    PGconn [int] return: [string!]]
    PQoptions      ["Options of connection"
                    PGconn [int] return: [string!]]
    PQport         ["Port number"
                    PGconn [int] return: [string!]]
    PQtty          ["Tty of database"
                    PGconn [int] return: [string!]]
    PQstatus       ["Status of connection"
                    PGconn [int] return: [int]]
    PQerrorMessage ["Error associated with connection"
                    PGconn [int] return: [string!]]
    PQfinish       ["Close connection"
                    PGconn [int]]
    PQreset        ["Reset communication with database"
                    PGconn [int]]
    PQexec         [ "Execute SQL statement"
                     PGconn [int] query [string!] return: [int]]
    PQresultStatus ["Status of query"
                    result [int] return: [int]]
    PQresStatus    ["Convert status to string"
                    res-stat [int] return: [string!]]
    PQresultErrorMessage ["Error message for query"
                          PGresult [int] return: [string!]]
    PQntuples   ["Number of tuples in result"
                 PGresult [int] return: [int]]
    PQnfields   ["Number of fields in result"
                 PGresult [int] return: [int]]
    PQfname     ["Field attribute associated with field index"
                 PGresult [int] field_index [int] return: [string!]]
    PQfnumber   ["Field index associated with field name"
                 PGresult [int] field_name [string!] return: [int]]
    PQftype     ["Field type associated with given index"
                 PGresult [int] field_num [int] return: [int]]
    PQfsize     ["Size in bytes of field associated with index"
                 PGresult [int] field_index [int] return: [int]]
    PQfmod      ["Type-specific modification data per field at index"
                 PGresult [int] field_index [int] return: [int]]
    PQgetvalue  ["Get field (attribute) value"
                 PGresult [int] tup_num [int] field_num [int] return: [char*]]
    PQgetlength ["Length of a field in bytes"
                 PGresult [int] tup_num [int] field_num [int] return: [int]]
    PQgetisnull ["NULL status of a field"
                 PGresult [int] tup_num [int] field_num [int] return: [int]]
    PQcmdStatus ["Command status of last query command"
                 PGresult [int] return: [string!]]
    PQcmdTuples ["Number of tuples affected by INSERT, UPDATE, DELETE queries"
                 PGresult [int] return: [string!]]
    PQoidStatus ["String with the object id  of  the tuple inserted"
                 PGresult [int] return: [string!]]
    PQclear        ["Frees the storage  associated  with  the  PGresult"
                    PQresult [int]]
    PQsendQuery    ["Submit a query to Postgres without waiting result(s)"
                    PGconn [int] query [string!] return: [string!]]
    PQgetResult    ["Wait for the next result from a prior PQsendQuery"
                    PGconn [int] return: [int]]
    PQconsumeInput ["If input is available from the backend, consume it"
                    PGconn [int]]
    PQisBusy       ["Returns TRUE if a query is busy (would block)"
                    PGconn [int] return: [int]]
    PQsocket       ["file descriptor number for the backend connection socket"
                    PGconn [int] return: [int]]
    PQrequestCancel["Request abandon processing of the current query"
                    PGconn [int] return: [int]]
    fe_getauthname ["Name the user has authenticated"
                    errorMessage [string!] return: [string!]]
    fe_setauthsvc  ["use authentication service name rather default"
                    name [string!] errorMessage [string!]]
]

foreach [name spec] routines [
    set name make routine! spec pq form name
]

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to