Skip to main content

Basic MySQL wrapper for object-oriented collection handling

Project description

Python Basic Utilities - MySQL pbumysql

Available on PyPi

This package is still in development!

Table of Contents

  1. Installation
  2. Usage
  3. Classes
    1. AbstractMysqlStore - abstract class for handling MySQL table access
    2. AbstractMysqlDocument - abstract class for wrapping rows representing entities
    3. MysqlConnection - a wrapper for a MySQL connection

Installation

Install via pip:

pip install pbumysql

Usage

It is good practice associating a sub-class of AbstractMysqlDocument with a sub-class of AbstractMysqlStore. This is done through the object_class parameter in the super() constructor call of the store class. Any method for querying rows will use that class to deserialise the row into the provided class, which should extend AbstractMysqlDocument.

Example: let's say we want to implement access to a collection containing user documents. We'll define a class User that extends AbstractMysqlDocument and a class UserStore that extends AbstractMysqlStore.

  • TODO: add code example of store and entity definition
  • TODO: add code example of store and entity usage

Classes

AbstractMysqlStore

This is an abstract class and cannot be instantiated directly. Instead, define a class that extends this class.

Constructor

__init__(connection, table_name, object_class, logger=None)

  • connection - an instance of MysqlConnection
  • table_name - the name of the table containing the rows
  • object_class - used for all the query methods to deserialise the row into a class with attributes for easier access
  • logger - a logger instance with .info / .error / .warn methods available

Methods

TODO: describe methods

AbstractMysqlDocument

TODO: add documentation

MysqlConnection

TODO: add documentation

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

pbumysql-0.1.0.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

pbumysql-0.1.0-py3-none-any.whl (11.1 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