Skip to content

Installation

Install from the community extension repository:

INSTALL monetary FROM community;
LOAD monetary;
-- Check extension is loaded
SELECT '100 EUR'::monetary;
-- Returns: 100.00 EUR
-- Check currency lookup works
SELECT currency_for_country('US');
-- Returns: USD

Add to your ~/.duckdbrc to load automatically:

INSTALL monetary FROM community;
LOAD monetary;

Or in Python:

import duckdb
conn = duckdb.connect()
conn.execute("INSTALL monetary FROM community")
conn.execute("LOAD monetary")
# Now use monetary types
result = conn.execute("SELECT '99.99 USD'::monetary").fetchone()
print(result[0]) # 99.99 USD

The extension auto-installs httpfs for exchange rate functions. No manual setup needed.


Terminal window
git clone https://github.com/fyffee/monetary.git
cd monetary/pg_monetary/cpp
make
sudo make install
CREATE EXTENSION pg_monetary;
-- Check monetary type
SELECT '100 EUR'::monetary;
-- Returns: 100.00 EUR
-- Check currency functions
SELECT currency_for_country('DE');
-- Returns: EUR
-- Check arithmetic
SELECT '50 USD'::monetary + '25 USD'::monetary;
-- Returns: 75.00 USD

If you use pgxman:

Terminal window
pgxman install pg_monetary

DatabaseMinimum Version
DuckDB1.4.3+
PostgreSQL14+

For contributors or those who want to build from source:

Terminal window
git clone https://github.com/fyffee/monetary.git
cd monetary
Terminal window
# Install devenv if you don't have it
curl -sfL https://devenv.sh/install.sh | bash
# Enter development environment
devenv shell
# Build all extensions
build-all
# Run tests
test-all
Terminal window
cd duckdb_monetary
make release GEN=ninja
# Run tests
make test GEN=ninja
Terminal window
cd pg_monetary/cpp
make
sudo make install
# Test
psql -c "CREATE EXTENSION pg_monetary;"
psql -c "SELECT '100 EUR'::monetary;"