Documentation

Hale.Hasql.Database.PostgreSQL.LibPQ

@[extern hale_pg_connect]

Connect to a PostgreSQL database using a connection string. $$\text{connect} : \text{String} \to \text{IO}\ \text{PgConn}$$ The connection string follows libpq format: "host=localhost port=5432 dbname=mydb user=myuser" or a URI "postgresql://user:pass@host/db".

Return the status of the connection. $$\text{status} : \text{PgConn} \to \text{IO}\ \text{ConnStatus}$$

Equations
Instances For
    @[extern hale_pg_error_message]

    Return the error message most recently generated by a connection operation.

    @[extern hale_pg_close]

    Close the connection immediately (before GC would finalize it).

    @[extern hale_pg_exec]

    Execute a simple SQL command (no parameters). $$\text{exec} : \text{PgConn} \to \text{String} \to \text{IO}\ \text{PgResult}$$

    @[extern hale_pg_exec_params]

    Execute a parameterized query. Parameters are passed as an array of optional strings (None = SQL NULL). $$\text{execParams} : \text{PgConn} \to \text{String} \to \text{Array}\ (\text{Option String}) \to \text{IO}\ \text{PgResult}$$

    @[extern hale_pg_prepare]
    opaque Database.PostgreSQL.LibPQ.prepare (conn : PgConn) (stmtName query : String) :

    Prepare a named statement for later execution. $$\text{prepare} : \text{PgConn} \to \text{String} \to \text{String} \to \text{IO}\ \text{PgResult}$$

    @[extern hale_pg_exec_prepared]

    Execute a previously prepared statement with the given parameters.

    @[extern hale_pg_result_error_message]

    Return the error message associated with a result, or empty string.

    @[extern hale_pg_ntuples]

    Return the number of rows in the result set.

    @[extern hale_pg_nfields]

    Return the number of columns in the result set.

    @[extern hale_pg_getvalue]

    Return the value at the given row and column as a string.

    @[extern hale_pg_getisnull]

    Return whether the value at the given position is NULL.

    @[extern hale_pg_fname]

    Return the column name at the given index.

    @[extern hale_pg_ftype]

    Return the OID of the column type at the given index.

    @[extern hale_pg_cmd_tuples]

    Return the number of rows affected by the command (as a string).

    @[extern hale_pg_escape_literal]

    Escape a string for use as an SQL literal (adds quotes). $$\text{escapeLiteral} : \text{PgConn} \to \text{String} \to \text{IO}\ \text{String}$$

    @[extern hale_pg_escape_identifier]

    Escape a string for use as an SQL identifier (adds double-quotes).

    @[extern hale_pg_consume_input]

    Consume any available input from the server (non-blocking). Returns true if no error occurred.

    @[extern hale_pg_notifies]

    Return the next notification from the server, if any.

    Execute a query and check the result status. Throws IO.userError if the result indicates an error.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Connect and verify the connection is OK. Throws IO.userError if the connection failed.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For