Firebird Base Modules
Firebird-base provides foundational modules for working with Firebird databases in Python, offering utilities for logging, configuration, buffering, event handling, and protobuf integration. It is actively maintained with regular patch and minor releases, typically quarterly, and had a major version bump to 2.0.0 in late 2023, raising the minimum Python version to 3.11. The current version is 2.0.2.
Common errors
-
TypeError: __signature__ must be an instance of inspect.Signature
cause An issue with signature matching in the `eventsocket` module was present in earlier versions.fixUpgrade `firebird-base` to version 2.0.1 or newer to resolve the signature mismatch. -
AttributeError: 'MemoryBuffer' object has no attribute 'get_raw'
cause The `get_raw` method was added to `MemoryBuffer` (and related buffer factories) in version 2.0.0.fixUpgrade `firebird-base` to version 2.0.0 or newer to use the `get_raw` method. -
ModuleNotFoundError: No module named 'firebird.base.logging.config'
cause The `firebird.base.logging` module was entirely rewritten in v2.0.0, changing its internal structure and API, including the removal of previous configuration modules.fixAdapt your logging code to the new API introduced in `firebird-base` v2.0.0. For basic usage, refer to `firebird.base.logging.get_logger()`. -
distutils.errors.DistutilsPlatformError: Python 3.10.x is not supported by Firebird Base Modules 2.0.0 and above.
cause Attempting to install or run `firebird-base` v2.0.0+ on a Python version older than 3.11.fixUpgrade your Python environment to 3.11 or newer, or specify an older compatible version of `firebird-base` (e.g., `pip install 'firebird-base<2.0.0'`).
Warnings
- breaking Version 2.0.0 and above require Python 3.11 or newer. Running on older Python versions will result in installation failures or runtime errors.
- breaking The `firebird.base.logging` module was completely reworked in v2.0.0. Existing code that directly imports `Logger` or `LogManager` classes, or relies on previous configuration methods, will break.
- gotcha Internal `_decompose` logic in `firebird.base.types` was adjusted in v1.4.3 and fixed again in v2.0.1 due to changes in Python 3.11's `enum` module. Using older versions of `firebird-base` (e.g., <1.4.3 or between 1.4.3 and 2.0.1) on Python 3.11 might lead to incorrect behavior with certain enum-like types.
- gotcha The `firebird.base.config` module's `EnvExtendedInterpolation` extends `configparser.ExtendedInterpolation` to automatically resolve 'env' section variables from environment variables. This might cause unexpected configuration values if environment variables with matching names exist but are not intended to be used.
Install
-
pip install firebird-base
Imports
- MemoryBuffer
from firebird.base.buffer import MemoryBuffer
- get_logger
from firebird.base.logging import Logger
from firebird.base.logging import get_logger
- Config
from firebird.base.config import Config
Quickstart
from firebird.base.buffer import MemoryBuffer
import io
# Create a MemoryBuffer with an initial capacity of 1KB
buffer = MemoryBuffer(1024)
# Write some bytes to the buffer
test_data = b"This is a test string to be written into the buffer."
buffer.write(test_data)
# Move the cursor to the beginning to read
buffer.seek(0, io.SEEK_SET)
# Read all data from the buffer
read_data = buffer.read()
# Get the raw underlying buffer content (new in v2.0.0)
raw_content = buffer.get_raw()
print(f"Original data: {test_data}")
print(f"Read data: {read_data}")
print(f"Raw buffer content (up to written length): {raw_content[:len(test_data)]}")
# Verify data
assert read_data == test_data
assert raw_content[:len(test_data)] == test_data
print("Buffer operations successful!")