-   [](https://platform.exaloop.io/)
-   Databases
-   [PostgreSQL](https://platform.exaloop.io/db/postgres/)
-   Deployment

# Deploy PostgreSQL Applications and Functions

A PostgreSQL client deploys as an executable with its native libraries. Server functions deploy into the database host and additionally depend on PostgreSQL's major-version ABI. Use the procedure below for the artifact you built, with an SDK and runtime matching the destination architecture.

## Client Applications

For a configured native project target, create a runtime package:

```sh title="Terminal"
exaloop --target app package --bundle-runtime
```

Keep the package directory intact and supply the connection configuration and TLS certificates separately. See [runtime packages](https://platform.exaloop.io/start/distribution/#runtime-only-packages) for target requirements and dynamically loaded libraries.

## Install Server Functions

The [function build](https://platform.exaloop.io/db/postgres/functions/) emits `codon_functions.control` and `codon_functions--0.1.0.sql`. To distribute a PostgreSQL extension, install the library under `pg_config --pkglibdir` and those two files under `pg_config --sharedir` in its `extension` subdirectory. These destinations often require administrator access. The `--version` option sets the extension version.

After installation, a database superuser can run:

```sql title="SQL"
CREATE EXTENSION codon_functions;
```

Use either extension installation or the direct development SQL script, not both for the same function names. The extension is relocatable and can be installed in a chosen schema. PostgreSQL's normal function privileges apply; review the default `PUBLIC` execute permission and grant access as appropriate.

Deploy the matching Codon runtime libraries alongside a suitable library search configuration. Python and the C compiler are build tools, not server-side execution dependencies. All Codon modules in a backend must use the same runtime.

PostgreSQL retains a loaded library for the backend's lifetime. Use a new library filename when deploying a revision, update the SQL definitions, and reconnect existing sessions. Do not overwrite a library being used by live backends or put these libraries in `shared_preload_libraries`.

## Server Safety

This API provides scalar functions that execute as native code inside a PostgreSQL backend, with the server process's privileges. Staging validation therefore needs representative workloads and database permissions, as well as a [compatible server and SDK](https://platform.exaloop.io/db/reference/#compatibility).

## Next Steps

-   [Review client connection settings](https://platform.exaloop.io/db/reference/#postgresql), including TLS and authentication.
-   [Prepare a production deployment](https://platform.exaloop.io/production/), including staging checks and rollback.

Source: https://platform.exaloop.io/db/postgres/deployment/
