Skip to main content

Database manager command line interface and API for yhttp.

Project description

yhttp-dbmanager

A yhttp extension to create and remove database(s) using command line and API.

Quickstart

Dependencies

Install postgresql brefore use of this project.

apt install postgresql

Prepare

Create and grant the postgresql role with createdb permission to authenticate the current unix user within postgresql using the peer authentication.

echo "CREATE USER ${USER} WITH CREATEDB" | sudo -u postgres psql
# Or
echo "ALTER USER ${USER} CREATEDB" | sudo -u postgres psql

Usage

Import and install the extension inside the roolup.py:

# foo/version.py
__version__ = '0.1.'
# foo/rollup.py
from yhttp.core import Application
from yhttp.ext import dbmanager

from .version import __version__


app = Application(__version__, 'foo')


# builtin settings
app.settings.merge('''
db:
  url: postgres://:@/ticketing
```)


# install extensions
dbmanager.install(app)


# http handlers
from . import handlers
# foo/__init__.py
from .version import __version__
from .rollup import app
# setup.py
import re
from os.path import join, dirname

from setuptools import setup, find_packages


# reading package version (same way the sqlalchemy does)
with open(join(dirname(__file__), 'foo/version.py')) as v_file:
    package_version = re.compile('.*__version__ = \'(.*?)\'', re.S).\
        match(v_file.read()).group(1)


dependencies = [
    'yhttp >= 7.0.1, < 8'
    'yhttp-dbmanager >= 5.0.1, < 6'
]


setup(
    name='foo',
    version=package_version,
    install_requires=dependencies,
    packages=find_packages(
        where='.',
        exclude=['tests']
    ),
    entry_points={
        'console_scripts': [
            'foo = foo:app.climain'
        ]
    },
)

After installing the extension these command line interfaces will be available as as subcommand of your application command line interface:

foo db --help

Contribution

Dependencies

Install postgresql brefore use of this project.

apt install postgresql

Prepare

Create and grant the postgresql role with createdb permission to authenticate the current unix user within postgresql using the peer authentication.

echo "CREATE USER ${USER} WITH CREATEDB" | sudo -u postgres psql
# Or
echo "ALTER USER ${USER} CREATEDB" | sudo -u postgres psql

Virtualenv

Create virtual environment:

make venv

Delete virtual environment:

make venv-delete

Activate the virtual environment:

source ./activate.sh

Install (editable mode)

Install this project as editable mode and all other development dependencies:

make env

Tests

Execute all tests:

make test

Execute specific test(s) using wildcard:

make test F=tests/test_db*
make test F=tests/test_form.py::test_querystringform

refer to pytest documentation for more info about invoking tests.

Execute tests and report coverage result:

make cover
make cover F=tests/test_static.py
make cover-html

Lint

make lint

Distribution

Execute these commands to create Python's standard distribution packages at dist directory:

make sdist
make wheel

Or

make dist

to create both sdidst and wheel packages.

Clean build directory

Execute:

make clean

to clean-up previous dist/* and build/* directories.

PyPI

WARNING: Do not do this if you'r not responsible as author and or maintainer of this project.

Execute

make clean
make pypi

to upload sdists and wheel packages on PyPI.

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

yhttp_dbmanager-8.0.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

yhttp_dbmanager-8.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file yhttp_dbmanager-8.0.1.tar.gz.

File metadata

  • Download URL: yhttp_dbmanager-8.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yhttp_dbmanager-8.0.1.tar.gz
Algorithm Hash digest
SHA256 9b5b4e2292dad78f7b39727e164ab2e127e0e3bb208465af318e0944cd037e15
MD5 3dc3533cfc1b1311de1a9356da084a32
BLAKE2b-256 e69d6186a64002864f693299e90f66612ea6c5a861a83e6f7b786eb0c930e7d9

See more details on using hashes here.

File details

Details for the file yhttp_dbmanager-8.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for yhttp_dbmanager-8.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f2e7a743acb0b20cb75872641faac0a787ce921961942c67b206eb9b79d7c119
MD5 ae6f55d955c88d85dc3b8ad620fad056
BLAKE2b-256 fa8650618a8b1590d4331ca7db4af9dd385bce45d944fff712ad0435bfcfcdac

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