Copyright © Roberto Saccon 2007
Authors: Roberto Saccon (rsaccon@gmail.com).
This module implements the Postgresql driver for ErlyDB.
Based on code initially developed by Brian Olson, see (http://groups.google.com/group/erlyweb/browse_frm/thread/e1585240f790c87c)
This is an internal ErlyDB module that you normally shouldn't have to use directly.
Postgresql driver is an OTP application. Define database details and authetication credentials for the driver pool in psql.app.src and run 'make app' to crate an OTP-ish ebin/psql.app
For license information see LICENSE.txt| get_last_insert_id/2 | Get the id of the last inserted record. |
| get_metadata/1 | Get the table names and fields for the database. |
| q/1 | Execute a statement directly against the PostgreSQL driver. |
| q/2 | |
| q2/1 | Execute a (binary or string) statement against the Postgresql driver using the default options. |
| q2/2 | Execute a (binary or string) statement against the MySQL driver. |
| select/2 | Execute a raw SELECT statement. |
| select_as/3 | Execute a SELECT statements for records belonging to the given module, returning all rows with additional data to support higher-level ErlyDB features. |
| start/0 | Starts the psql and sql applications up if they are not already started. |
| stop/0 | Stops the psql and sql applications. |
| transaction/2 | Models a transaction. |
| update/2 | Execute a INSERT, DELETE or UPDATE statement. |
get_last_insert_id(TableName::atom(), Options::proplist()) -> term()
Get the id of the last inserted record.
Get the table names and fields for the database.
Execute a statement directly against the PostgreSQL driver. If Options contains the value {allow_unsafe_sql, true}, binary and string queries as well as ErlSQL queries with binary and/or string expressions are accepted. Otherwise the function crashes.
q2(Statement::string() | binary()) -> psql_result()
Execute a (binary or string) statement against the Postgresql driver using the default options.
q2(Statement::string() | binary(), Options::proplist()) -> psql_result()
Execute a (binary or string) statement against the MySQL driver.
select(PoolId::atom(), Statement::statement()) -> {ok, Rows::list()} | {error, Error}
Execute a raw SELECT statement.
select_as(Module::atom(), Statement::statement(), FixedCols::tuple()) -> {ok, Rows} | {error, Error}
Execute a SELECT statements for records belonging to the given module, returning all rows with additional data to support higher-level ErlyDB features.
Starts the psql and sql applications up if they are not already started. Any errors that are returned are ignored.
Stops the psql and sql applications.
Models a transaction. If an error occurs in the function provided, then the transaction will rollback. Otherwise it will commit.
update(Statement::statement(), Options::options()) -> {ok, NumAffected} | {error, Err}
Execute a INSERT, DELETE or UPDATE statement.