Liking cljdoc? Tell your friends :D

pg.core

Common API to communicate with PostgreSQL server.

Common API to communicate with PostgreSQL server.
raw docstring

->codec-paramsclj

(->codec-params opt)
source

->configclj

(->config params)

Turn a Clojure map into an instance of Config.Builder.

Turn a Clojure map into an instance of Config.Builder.
sourceraw docstring

->enumclj

(->enum x)

Wrap a value with a PGEnum class for proper enum encoding

Wrap a value with a PGEnum class for proper enum encoding
sourceraw docstring

->execute-paramsclj

(->execute-params opt)

Make an instance of ExecuteParams from a Clojure map.

Make an instance of ExecuteParams from a Clojure map.
sourceraw docstring

->kebabclj

(->kebab column)

Turn a string column name into into a kebab-case formatted keyword.

Turn a string column name into into  a kebab-case
formatted keyword.
sourceraw docstring

->tx-levelclj

(->tx-level level)

Turn a keyword or a string into on instance of TxLevel.

Turn a keyword or a string into on instance of TxLevel.
sourceraw docstring

beginclj

(begin conn)
(begin conn tx-level)
(begin conn tx-level read-only?)

Open a new transaction. Possible arguments:

  • tx-level: the custom isolation level, either a :kebab-case keyword, or a CAPS STRING, for example :read-committed or 'READ COMMITTED';
  • read-only?: whether to run the transaction in read-only mode (default is false).
Open a new transaction. Possible arguments:

- `tx-level`: the custom isolation level, either a `:kebab-case`
   keyword, or a CAPS STRING, for example `:read-committed`
   or `'READ COMMITTED'`;
- `read-only?`: whether to run the transaction in read-only mode
  (default is false).
sourceraw docstring

cancel-requestclj

(cancel-request conn)

Send a cancellation request to the server. MUST be called in another thread! The cancellation is meant to interrupt a query that has frozen the server. There is no 100% guarantee it will work.

Not recommended to use directly. See the with-timeout macro.

Send a cancellation request to the server. MUST be called
in another thread! The cancellation is meant to interrupt
a query that has frozen the server. There is no 100% guarantee
it will work.

Not recommended to use directly. See the `with-timeout` macro.
sourceraw docstring

cloneclj

(clone conn)

Create a new Connection from a configuration of the given connection.

Create a new Connection from a configuration of the given connection.
sourceraw docstring

closeclj

(close conn)

Close the connection to the database.

Close the connection to the database.
sourceraw docstring

close-statementclj

(close-statement conn stmt)

Close the prepared statement.

Close the prepared statement.
sourceraw docstring

closed?clj

(closed? conn)

True if the connection has been closed.

True if the connection has been closed.
sourceraw docstring

commitclj

(commit conn)

Commit the current transaction.

Commit the current transaction.
sourceraw docstring

connectclj

(connect config)
(connect host port user password database)

Connect to the database. Given a Clojure config map, establish a TCP connection with the server and run the authentication pipeline. Returns an instance of the Connection class.

Connect to the database. Given a Clojure config map,
establish a TCP connection with the server and run
the authentication pipeline. Returns an instance of
the Connection class.
sourceraw docstring

connection?clj

(connection? x)

True of the passed option is a Connection instance.

True of the passed option is a Connection instance.
sourceraw docstring

copy-inclj

(copy-in conn sql in)
(copy-in conn sql in opt)

Transfer the data from the client to the server using COPY protocol. The SQL expression must be something liek this:

COPY ... FROM STDIN ...

The in parameter is an instance of InputStream. The function doesn't close the stream assuming you can reuse it.

The opt map is used to specify format, CSV delimiters, type hints and other options (see README).

Return the number of rows processed by the server.

Transfer the data from the client to the server using
COPY protocol. The SQL expression must be something liek this:

`COPY ... FROM STDIN ...`

The `in` parameter is an instance of `InputStream`. The function
doesn't close the stream assuming you can reuse it.

The `opt` map is used to specify format, CSV delimiters, type hints
and other options (see README).

Return the number of rows processed by the server.
sourceraw docstring

copy-in-mapsclj

(copy-in-maps conn sql maps keys)
(copy-in-maps conn sql maps keys opt)

Like copy-in but accepts a list of Clojure maps.

The keys argument is list of keys which is used to convert each map into a tuple.

The opt argument is a map of options (COPY format, delimiters, etc).

Return the number of rows processed by the server.

Like `copy-in` but accepts a list of Clojure maps.

The `keys` argument is list of keys which is used to convert
each map into a tuple.

The `opt` argument is a map of options (COPY format, delimiters, etc).

Return the number of rows processed by the server.
sourceraw docstring

copy-in-rowsclj

(copy-in-rows conn sql rows)
(copy-in-rows conn sql rows opt)

Like copy-in but accepts not an input stream but a list of rows. Each row must be a list of values. The list might be lazy. Return a number of rows processed.

Like `copy-in` but accepts not an input stream but a list
of rows. Each row must be a list of values. The list might be
lazy. Return a number of rows processed.
sourceraw docstring

copy-outclj

(copy-out conn sql out)
(copy-out conn sql out opt)

Transfer the data from the server to the client using COPY protocol. The SQL expression must be something like this:

COPY ... TO STDOUT ...

The out parameter must be an instance of OutputStream.

The function doesn't close the stream assuming you can reuse it for multiple COPY OUT sessions.

The opt map allows to specify the data format, CSV delimiters other options (see the docs in README).

Return the number of rows read from the server.

Transfer the data from the server to the client using
COPY protocol. The SQL expression must be something like this:

`COPY ... TO STDOUT ...`

The `out` parameter must be an instance of OutputStream.

The function doesn't close the stream assuming you can reuse it
for multiple COPY OUT sessions.

The `opt` map allows to specify the data format, CSV delimiters
other options (see the docs in README).

Return the number of rows read from the server.
sourceraw docstring

COPY_FORMAT_BINclj

source

COPY_FORMAT_CSVclj

source

COPY_FORMAT_TABclj

source

created-atclj

(created-at conn)

Get the creation time as Unix timestamp (ms).

Get the creation time as Unix timestamp (ms).
sourceraw docstring

decode-binclj

(decode-bin buf oid)
(decode-bin buf oid opt)

Decode a binary-encoded value from a ByteBuffer.

Decode a binary-encoded value from a ByteBuffer.
sourceraw docstring

decode-txtclj

(decode-txt obj oid)
(decode-txt obj oid opt)

Decode a text-encoded value from a ByteBuffer.

Decode a text-encoded value from a ByteBuffer.
sourceraw docstring

encode-binclj

(encode-bin obj)
(encode-bin obj oid)
(encode-bin obj oid opt)

Binary-encode a value into a ByteBuffer.

Binary-encode a value into a ByteBuffer.
sourceraw docstring

encode-txtclj

(encode-txt obj)
(encode-txt obj oid)
(encode-txt obj oid opt)

Text-encode a value into a ByteBuffer.

Text-encode a value into a ByteBuffer.
sourceraw docstring

error!clj

(error! template & args)
source

executeclj

(execute conn sql)
(execute conn sql opt)

Execute a SQL expression and return the result.

This function is a series of steps:

  • prepare a statement;
  • bind parameters and obtain a portal;
  • describe the portal;
  • get the data from the portal;
  • close the portal;
  • close the statement;
  • process the result of the fly.
Execute a SQL expression and return the result.

This function is a series of steps:
- prepare a statement;
- bind parameters and obtain a portal;
- describe the portal;
- get the data from the portal;
- close the portal;
- close the statement;
- process the result of the fly.
sourceraw docstring

execute-statementclj

(execute-statement conn stmt)
(execute-statement conn stmt opt)

Execute the given prepared statement and get the result. The way the result is processed heavily depends on the options.

Execute the given prepared statement and get the result.
The way the result is processed heavily depends on the options.
sourceraw docstring

get-error-fieldsclj

(get-error-fields e)
source

get-parameterclj

(get-parameter conn param)

Return a certain connection parameter by its name, e.g. 'server_encoding', 'application_name', etc.

Return a certain connection parameter by its name, e.g.
'server_encoding', 'application_name', etc.
sourceraw docstring

get-parametersclj

(get-parameters conn)

Return a {String->String} map of all the connection parameters.

Return a {String->String} map of all the connection parameters.
sourceraw docstring

IConnectablecljprotocol

-borrow-connectionclj

(-borrow-connection this)

-return-connectionclj

(-return-connection this conn)
source

idclj

(id conn)

Get a unique ID of the connection.

Get a unique ID of the connection.
sourceraw docstring

idle?clj

(idle? conn)

True if the connection is in the idle state.

True if the connection is in the idle state.
sourceraw docstring

in-transaction?clj

(in-transaction? conn)

True if the connection is in transaction at the moment.

True if the connection is in transaction at the moment.
sourceraw docstring

is-ssl?clj

(is-ssl? conn)

True if the Connection is SSL-encrypted.

True if the Connection is SSL-encrypted.
sourceraw docstring

json-wrapclj

(json-wrap x)

Wrap a value into a JSON.Wrapper class to force JSON encoding.

Wrap a value into a JSON.Wrapper class to force JSON encoding.
sourceraw docstring

listenclj

(listen conn channel)

Subscribe the connection to a given channel.

Subscribe the connection to a given channel.
sourceraw docstring

notifyclj

(notify conn channel message)

Send a text message to the given channel.

Send a text message to the given channel.
sourceraw docstring

on-connectioncljmacro

(on-connection [bind source] & body)

Perform a block of code while the bind symbol is bound to a Connection object. If the source is a config map, the connection gets closed. When the source is a pool, the connection gets borrowed and returned afterwards. For existing connection, nothing is happening at the end.

Perform a block of code while the `bind` symbol is bound
to a `Connection` object. If the source is a config map,
the connection gets closed. When the source is a pool,
the connection gets borrowed and returned afterwards.
For existing connection, nothing is happening at the end.
sourceraw docstring

pidclj

(pid conn)

Get PID of the connection on the server.

Get PID of the connection on the server.
sourceraw docstring

prepareclj

(prepare conn sql)
(prepare conn sql opt)

Get a new prepared statement from a raw SQL string. The SQL might have parameters. There is an third optional parameter oids to specify the non-default types of the parameters. Must be a List of OID enum.

The function returns an instance of the PreparedStatement class bound to the current connection.

Get a new prepared statement from a raw SQL string.
The SQL might have parameters. There is an third
optional parameter `oids` to specify the non-default types
of the parameters. Must be a List of OID enum.

The function returns an instance of the `PreparedStatement`
class bound to the current connection.
sourceraw docstring

prepared-statement?clj

(prepared-statement? x)

True if it's an instance of the PreparedStatement class.

True if it's an instance of the PreparedStatement class.
sourceraw docstring

queryclj

(query conn sql)
(query conn sql opt)

Run a SQL expression WITH NO parameters. The result gets sent back in text mode always by the server.

Run a SQL expression WITH NO parameters. The result
gets sent back in text mode always by the server.
sourceraw docstring

rollbackclj

(rollback conn)

Rollback the current transaction.

Rollback the current transaction.
sourceraw docstring

set-read-onlyclj

(set-read-only conn)

Set the current transaction read-only.

Set the current transaction read-only.
sourceraw docstring

set-tx-levelclj

(set-tx-level conn level)

Set transaction isolation level for the current transaction.

Set transaction isolation level for the current transaction.
sourceraw docstring

ssl-contextclj

(ssl-context {:keys [key-file cert-file ca-cert-file]})

Build a SSLContext instance from a Clojure map. All the keys point to local files.

Build a SSLContext instance from a Clojure map.
All the keys point to local files.
sourceraw docstring

ssl-context-readerclj

(ssl-context-reader mapping)
source

ssl?clj

(ssl? conn)

True if the connection is encrypted with SSL.

True if the connection is encrypted with SSL.
sourceraw docstring

statusclj

(status conn)

Return the current transaction status, one of :I, :T, or :E.

Return the current transaction status, one of :I, :T, or :E.
sourceraw docstring

tx-error?clj

(tx-error? conn)

True if the transaction has failed but hasn't been rolled back yet.

True if the transaction has failed but hasn't been
rolled back yet.
sourceraw docstring

TX_READ_COMMITTEDclj

source

TX_READ_UNCOMMITTEDclj

source

TX_REPEATABLE_READclj

source

TX_SERIALIZABLEclj

source

unlistenclj

(unlisten conn channel)

Unsubscribe the connection from a given channel.

Unsubscribe the connection from a given channel.
sourceraw docstring

with-conncljmacro

(with-conn [bind config] & body)

Just a shorter version of with-connection.

Just a shorter version of `with-connection`.
sourceraw docstring

with-connectioncljmacro

(with-connection [bind config] & body)

Execute the body while the bind symbol is bound to the new Connection instance. The connection gets closed when exiting the macro.

Execute the body while the `bind` symbol is bound to the
new Connection instance. The connection gets closed when
exiting the macro.
sourceraw docstring

with-lockcljmacro

(with-lock [conn] & body)
source

with-statementcljmacro

(with-statement [bind conn sql oids] & body)

Execute the body while the bind symbol is bound to the new PreparedStatement instance. The statement gets created from the SQL expression and optional list of OIDs. It gets closed when exiting the macro.

Execute the body while the `bind` symbol is bound to the
new PreparedStatement instance. The statement gets created
from the SQL expression and optional list of OIDs. It gets
closed when exiting the macro.
sourceraw docstring

with-timeoutcljmacro

(with-timeout [conn ms-timeout] & body)

Set a timeout in which, if a query has not been executed in time, a cancellation request is sent to the server. Wrap a query with that macro when there is a chance for a server to freeze completely due to a non-optimized SQL. The ms-timeout is amount of milliseconds in which the cancel request will be sent.

Set a timeout in which, if a query has not been executed in time,
a cancellation request is sent to the server. Wrap a query with
that macro when there is a chance for a server to freeze completely
due to a non-optimized SQL. The `ms-timeout` is amount of milliseconds
in which the cancel request will be sent.
sourceraw docstring

with-txcljmacro

(with-tx [conn] & body)
(with-tx [conn {:keys [isolation-level read-only? rollback?]}] & body)

Wrap a block of code into a transaction, namely:

  • run BEGIN before executing the code;
  • capture all possible exceptions;
  • should an exception was caught, ROLLBACK...
  • and re-throw it;
  • if no exception was caught, COMMIT.

Accepts a map of the following options:

  • isolation-level: a keyword/string to set the isolation level;
  • read-only?: to set the transaction read only;
  • rollback?: to ROLLBACK a transaction even if it was successful.

Nested transactions are consumed by the most outer transaction. For example, you have two nested with-tx blocks:

(with-tx [...] ;; 1 (do-this ...) (with-tx [...] ;; 2 (do-that ...)))

In this case, only the first block will produce BEGIN and COMMIT commands. The second block will expand into the body only:

(pg/begin ...) (do-this ...) (do-that ...) (pg/commit ...)

Wrap a block of code into a transaction, namely:

- run BEGIN before executing the code;
- capture all possible exceptions;
- should an exception was caught, ROLLBACK...
- and re-throw it;
- if no exception was caught, COMMIT.

Accepts a map of the following options:

- isolation-level: a keyword/string to set the isolation level;
- read-only?: to set the transaction read only;
- rollback?: to ROLLBACK a transaction even if it was successful.

Nested transactions are consumed by the most outer transaction.
For example, you have two nested `with-tx` blocks:

(with-tx [...]          ;; 1
  (do-this ...)
  (with-tx [...]        ;; 2
    (do-that ...)))

In this case, only the first block will produce `BEGIN` and `COMMIT`
commands. The second block will expand into the body only:

(pg/begin ...)
  (do-this ...)
  (do-that ...)
(pg/commit ...)

sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close