https://github.com/asfernandes/fb-cpp
A modern C++ wrapper for the Firebird database API
https://github.com/asfernandes/fb-cpp
firebird firebirdsql
Last synced: 23 days ago
JSON representation
A modern C++ wrapper for the Firebird database API
- Host: GitHub
- URL: https://github.com/asfernandes/fb-cpp
- Owner: asfernandes
- License: mit
- Created: 2024-09-28T01:18:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-06-17T01:52:53.000Z (about 1 month ago)
- Last Synced: 2026-06-17T03:24:14.464Z (about 1 month ago)
- Topics: firebird, firebirdsql
- Language: C++
- Homepage: https://asfernandes.github.io/fb-cpp
- Size: 1.1 MB
- Stars: 18
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
# fb-cpp

A modern C++ wrapper for the Firebird database API.
[Documentation](https://asfernandes.github.io/fb-cpp) | [Repository](https://github.com/asfernandes/fb-cpp) |
[DeepWiki](https://deepwiki.com/asfernandes/fb-cpp)
## Overview
`fb-cpp` provides a clean, modern C++ interface to the Firebird database engine.
It wraps the Firebird C++ API with RAII principles, smart pointers, and modern C++ features.
## Features
- **Modern C++**: Uses C++20 features for type safety and performance
- **RAII**: Automatic resource management with smart pointers
- **Type Safety**: Strong typing for database operations
- **Exception Safety**: Proper error handling with exceptions
- **Boost Integration**: Optional Boost.DLL for loading fbclient and Boost.Multiprecision support for large numbers
## Quick Start
```cpp
#include "fb-cpp/fb-cpp.h"
using namespace fbcpp;
// Create a client
Client client{"fbclient"};
// Connect to a database
const auto attachmentOptions = AttachmentOptions()
.setConnectionCharSet("UTF8");
Attachment attachment{client, "localhost:database.fdb", attachmentOptions};
// Start a transaction
const auto transactionOptions = TransactionOptions()
.setIsolationLevel(TransactionIsolationLevel::READ_COMMITTED);
Transaction transaction{attachment, transactionOptions};
// Prepare a statement
Statement statement{attachment, transaction, "select id, name from users where id = ?"};
// Set parameters
statement.setInt32(0, 42);
/*
// Or:
statement.set(0, 42);
// Or:
statement.set(SomeStructOrTuple{42});
*/
// Execute and get results
if (statement.execute(transaction))
{
// Process results...
do
{
const std::optional id = statement.getInt32(0);
const std::optional name = statement.getString(1);
/*
// Or:
const auto id = statement.get(0);
const auto name = statement.get(1);
// Or:
const auto [id, name] = statement.get();
*/
} while (statement.fetchNext());
}
// Commit transaction
transaction.commit();
```
## Using with vcpkg
This library is present in [firebird-vcpkg-registry](https://github.com/asfernandes/firebird-vcpkg-registry).
To install, add the registry or overlay to your vcpkg configuration and install the `fb-cpp` package:
```bash
vcpkg install fb-cpp
```
Or add it to your `vcpkg.json` manifest:
```json
{
...
"dependencies": [
{
"name": "fb-cpp",
"default-features": true
}
]
}
```
The default features are:
- `boost-dll`: Enable Boost.DLL support for runtime dynamic loading of Firebird client library
- `boost-multiprecision`: Enable Boost.Multiprecision support for INT128 and DECFLOAT types
## Building
This project uses CMake presets (`CMakePresets.json`) and vcpkg for dependency management.
Copy the appropriate `CMakeUserPresets.json..template` file to `CMakeUserPresets.json` to set environment
variables for tests and define the default preset. On Windows, use either `CMakeUserPresets.json.windows-vs2022.template`
or `CMakeUserPresets.json.windows-vs2026.template`.
```bash
# Configure
cmake --preset default
# Build
cmake --build --preset default
# Run tests
ctest --preset default
# Build docs
cmake --build --preset default --target docs
```
## Documentation
The complete API documentation is available in the build `doc/docs/` directory after building with the `docs` target.
## License
MIT License - see LICENSE.md for details.
# Donation
If this project help you reduce time to develop, you can show your appreciation with a donation.
- GitHub Sponsor: https://github.com/sponsors/asfernandes
- Pix (Brazil): 278dd4e5-8226-494d-93a9-f3fb8a027a99
- BTC: 1Q1W3tLD1xbk81kTeFqobiyrEXcKN1GfHG
- [](https://www.paypal.com/donate/?hosted_button_id=DLH4FB4NJL8NS)