Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adjust/pg-currency
1 Byte Currency ISO type for PostgreSQL
https://github.com/adjust/pg-currency
postgresql
Last synced: 2 months ago
JSON representation
1 Byte Currency ISO type for PostgreSQL
- Host: GitHub
- URL: https://github.com/adjust/pg-currency
- Owner: adjust
- License: mit
- Created: 2015-03-17T14:04:58.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T12:43:07.000Z (9 months ago)
- Last Synced: 2024-05-09T08:10:52.544Z (8 months ago)
- Topics: postgresql
- Language: C
- Homepage:
- Size: 54.7 KB
- Stars: 12
- Watchers: 63
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CI](https://github.com/adjust/pg-currency/actions/workflows/main.yml/badge.svg)](https://github.com/adjust/pg-currency/actions/workflows/main.yml)
# PG Currency
A 1-byte ISO 4217 Currency Code data-type for PostgreSQL.
### Installation
You can clone the extension and run the standard `make && make install` to
build it against your PostgreSQL server.### Usage
The currency extension defines a data-type `currency`, which can be used, for
example, in `CREATE TABLE` statements. There're also comparison operators to
support ordering and `btree` indexing.#### Using the currency data-type
The following example illustrates the use of the `country` type.
```SQL
CREATE TABLE transactions (id serial, payment_currency currency);INSERT INTO transactions (values
(1, 'USD'),
(2, 'EUR'),
(3, 'USD')
);SELECT * FROM transactions ORDER BY payment_currency;
```The result from the above execution will be:
```
id | payment_currency
----+------------------
2 | EUR
1 | USD
3 | USD
(3 rows)
```#### List of supported currencies
To get a list of supported for the installed version, you can use the `supported_currencies` SRF.
```
SELECT * FROM supported_currencies();
```This will return a set of the supported currencies with no specific ordering.
```
SELECT * FROM supported_currencies() currency ORDER BY currency;
```### Development
To run the tests, clone and run `make && make install && make installcheck`.
[Dumbo](https://github.com/adjust/dumbo) is the recommended development tool for
the extension.