Skip to main content

SQL Store for the API Billing Backend

Project description

Frappy Python SQL Store for API Billing

Python SQLAlchemy Store Implementation for Tracking API Billing Usage.

Usage

from frappysqlapibilling import UsageStore
from frappyapibilling import ApiBilling
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

# create flask app
app = Flask(__name__)

# create SQL DB connection
sql_host, sql_port, sql_user, sql_pass, sql_db = ...
sql_connect_str = f"{sql_user}:{sql_pass}@{sql_host}:{sql_port}/{sql_db}"
# example for postgres
app.config["SQLALCHEMY_DATABASE_URI"] = f"postgresql+psycopg2://{sql_connect_str}"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
# create db
sql_db = SQLAlchemy(app)

# create sql store
store = UsageStore(sql_db=sql_db, table_name="api_billing_usage")  # table name defaults to "api_billing_usage"

# pass the store instance to the api billing constructor
api_billing = ApiBilling(usage_store=store)

See API Billing Usage for details on how to use the module.

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

frappysqlapibilling-0.1.0.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

frappysqlapibilling-0.1.0-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

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