pg_oxr
is a PostgreSQL extension that integrates with the OpenExchangeRates API, enabling you to fetch and manage currency exchange rates directly within your database. This extension simplifies workflows requiring real-time exchange rate data in PostgreSQL.
- Fetch Exchange Rates: Seamlessly retrieve live exchange rates from OpenExchangeRates.
- Configuration Management: Manage API keys and settings using PostgreSQL functions.
- Integrated Workflow: Combine exchange rate data with existing database operations for analytics or reporting.
Before installing pg_oxr
, ensure you have the following:
- PostgreSQL 13 or higher.
- Access to the OpenExchangeRates API (requires an API key).
- Build tools such as
make
andgcc
.
-
Clone the Repository:
git clone https://github.com/yourusername/pg_oxr.git cd pg_oxr
-
Build and Install the Extension:
make sudo make install
-
Enable the Extension in Your Database:
CREATE EXTENSION oxr;
To configure the extension, set the API key for OpenExchangeRates in your database using the configuration function:
-- Store your API key (replace 'your_api_key' with your actual key)
SELECT oxr.set_config('api_key', 'your_api_key');
Once configured, use the provided functions to interact with the API. For example:
-
Get the Current Exchange Rate:
SELECT oxr.get_exchange_rate('USD', 'EUR');
-
Fetch and Store Rates: Automate fetching exchange rates periodically to store them in a local table for quick access.
-
Custom Integrations: Combine
oxr
functions with other SQL queries for analytics, billing, or reporting workflows.
We welcome contributions to enhance the functionality of pg_oxr
. To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request with detailed explanations of changes.
This project is licensed under the MIT License. See the LICENSE.txt file for details.
Special thanks to the PostgreSQL and OpenExchangeRates teams for their excellent tools and services that made this extension possible.