Skip to main content

CF_API_TOKEN = _must_env("CF_API_TOKEN") CF_ACCOUNT_ID = _must_env("CF_ACCOUNT_ID") CF_D1_DATABASE_ID = _must_env("CF_D1_DATABASE_ID") CF_A…

Project description

PyPI version License: MIT Downloads LinkedIn

cf_d1_manager

A Python package to easily retrieve Cloudflare D1 configuration from environment variables.

Installation

To install cf_d1_manager, use pip:

pip install cf_d1_manager

Usage

The cf_d1_manager package provides a single function, get_cf_d1_config(), which reads required Cloudflare D1 configuration from environment variables.

Environment Variables Required:

  • CF_API_TOKEN: Your Cloudflare API token.
  • CF_ACCOUNT_ID: Your Cloudflare account ID.
  • CF_D1_DATABASE_ID: The ID of your D1 database.

Example

Here's how you can use get_cf_d1_config() in your Python script:

import os
from cf_d1_manager import get_cf_d1_config

# Set dummy environment variables for demonstration
os.environ["CF_API_TOKEN"] = "your_api_token"
os.environ["CF_ACCOUNT_ID"] = "your_account_id"
os.environ["CF_D1_DATABASE_ID"] = "your_database_id"

try:
    config = get_cf_d1_config()
    print("Cloudflare D1 Configuration:")
    print(f"  API Token: {config['CF_API_TOKEN']}")
    print(f"  Account ID: {config['CF_ACCOUNT_ID']}")
    print(f"  Database ID: {config['CF_D1_DATABASE_ID']}")
except ValueError as e:
    print(f"Error: {e}")

# Clean up dummy environment variables
del os.environ["CF_API_TOKEN"]
del os.environ["CF_ACCOUNT_ID"]
del os.environ["CF_D1_DATABASE_ID"]

If any of the required environment variables are not set, get_cf_d1_config() will raise a ValueError.

Author

Eugene Evstafev hi@eugene.plus

Repository

https://github.com/chigwell/cf_d1_manager

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

cf_d1_manager is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cf_d1_manager-2025.9.14920.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cf_d1_manager-2025.9.14920-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file cf_d1_manager-2025.9.14920.tar.gz.

File metadata

  • Download URL: cf_d1_manager-2025.9.14920.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for cf_d1_manager-2025.9.14920.tar.gz
Algorithm Hash digest
SHA256 2c8f1f46b525064ecbff2f7bb23f80c2bb3c568b1b717a394f6e2131b059dec7
MD5 1578e4a48135a046a5223c40c108ecaa
BLAKE2b-256 c98d0893d4be37eebc0635f460aec98d1eafffe169331627976b32457b57e5f5

See more details on using hashes here.

File details

Details for the file cf_d1_manager-2025.9.14920-py3-none-any.whl.

File metadata

File hashes

Hashes for cf_d1_manager-2025.9.14920-py3-none-any.whl
Algorithm Hash digest
SHA256 765f4405fae9b652e78c04c5ec3b65073493228e7a5da8ba36f2969ed4de72cf
MD5 37fc015788c89126c19d77da30c95392
BLAKE2b-256 49b010746b3edc0b93dc0ebe2c52f28a4a718b50704fff0cf519429b66228e9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page