semvec/pypi-packages huggingface dataset:
cf-db-table-reader 0.1.0
Query Cloudflare-protected tables using environment-provided credentials and return results as dictionaries.
License: MIT
Requires Python: >=3.6

[![PyPI version](https://badge.fury.io/py/cf-db-table-reader.svg)](https://badge.fury.io/py/cf-db-table-reader)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://static.pepy.tech/badge/cf-db-table-reader)](https://pepy.tech/project/cf-db-table-reader)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-blue)](https://www.linkedin.com/in/eugene-evstafev-716669181/)

# cf-db-table-reader

`cf-db-table-reader` is a simple Python package that retrieves data from a Cloudflare-hosted database table using Cloudflare's REST API. It automatically reads API credentials and account information from environment variables and provides an easy-to-use function to query data with optional filters.

## Installation

To install `cf-db-table-reader`, use pip:

```bash
pip install cf-db-table-reader
```

## Usage

Here's a short example demonstrating how to query data:

```python
import os
from cf_db_table_reader import cf_table_query

# Ensure environment variables are set:
# CF_API_TOKEN and CF_ACCOUNT_ID

# Query all entries in the table
results = cf_table_query(db_id="your_db_id", table_name="your_table_name")

# Query with filters
active_users = cf_table_query(db_id="your_db_id", table_name="your_table_name", filters={"status": "active"})

print(results)
print(active_users)
```

## Example

Suppose you want to retrieve all records with the status "active" from your table:

```python
import os
from cf_db_table_reader import cf_table_query

os.environ["CF_API_TOKEN"] = "your_api_token"
os.environ["CF_ACCOUNT_ID"] = "your_account_id"

active_records = cf_table_query(db_id="my_database", table_name="users", filters={"status": "active"})
for record in active_records:
    print(record)
```

This will output a list of dictionaries representing the matching rows.

## Author

Eugene Evstafev <hi@eugene.plus>

## License

This project is licensed under the MIT License. See the [LICENSE](https://opensource.org/licenses/MIT) file for details.

## Repository

<https://github.com/chigwell/cf_db_reader>