Skip to main content

Python small, little, mini, tiny, micro Object-Relational Mapping (ORM)

Project description

Perseus MicrORM

Majormode Perseus MicrORM Python Library is a small, little, mini, tiny, micro Object-Relational Mapping (ORM).

MicrORM is not a object-relational mapping in the sense it maps Pyth objects to a Relational DataBase Management System (RDBMS), but in the sense it maps results of SQL queries, executed on a RDBMS, to Python objects.

Installation

To install Perseus MicrORM Python Library, simply enter the follow command line:

pip install perseus-microrm-library

Usage

import uuid

from majormode.perseus.utils import cast
from majormode.perseus.utils.rdbms import RdbmsConnection


RDBMS_CONNECTION_PROPERTIES = {
    None: {
        'rdbms_hostname': 'localhost',
        'rdbms_port': 5432,
        'rdbms_database_name': 'foo',
        'rdbms_account_username': 'dbo',
        'rdbms_account_password': ''
    }
}

PLACE_IDS = [
    uuid.UUID('54879ffc-a1ec-11e8-85bd-0008a20c190f'),
    uuid.UUID('9025d1c8-a1ec-11e8-9e29-0007cb040bcc')
]

with RdbmsConnection.acquire_connection(
        RDBMS_CONNECTION_PROPERTIES,
        auto_commit=False,
        connection=None) as connection:
    cursor = connection.execute(
        """
        SELECT place_id,
               ST_X(location) AS longitude,
               ST_Y(location) AS latitude,
               ST_Z(location) AS altitude,
               accuracy,
               creation_time
          FROM place
          WHERE place_id IN %[place_ids]s
        """,
        {
            'place_ids': PLACE_IDS 
        })
    rows = cursor.fetch_all()

    places = [
        row.get_object({
            'place_id': cast.string_to_uuid,
            'creation_time': cast.string_to_timestamp})
        for row in cursor.fetch_all()]

    for place in places:
        print(place.place_id, place.longitude, place.latitude)

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

perseus-microrm-library-1.3.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

perseus_microrm_library-1.3.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file perseus-microrm-library-1.3.2.tar.gz.

File metadata

  • Download URL: perseus-microrm-library-1.3.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0

File hashes

Hashes for perseus-microrm-library-1.3.2.tar.gz
Algorithm Hash digest
SHA256 538087f823ab3dd522a8d6cbff1d39f23ceb2081f10b3b73cc7f0737c127b34b
MD5 6ae61b4dd76d2c6c616011d151439be2
BLAKE2b-256 7167bf72f81f26418ad3dcfa27b48c5bcfdca429160727dc3a3b0d1eb96f8227

See more details on using hashes here.

File details

Details for the file perseus_microrm_library-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: perseus_microrm_library-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0

File hashes

Hashes for perseus_microrm_library-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e86138de6ada530b247b81c49925dbce22b44fba5244d32de425837ae77e72f7
MD5 75acb203597b8f0bf14a4fe305b29325
BLAKE2b-256 b88a483937492346dc83bee9e8c539703821812ee1b75b35559364245af31715

See more details on using hashes here.

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