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.6.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

perseus_microrm_library-1.3.6-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file perseus_microrm_library-1.3.6.tar.gz.

File metadata

  • Download URL: perseus_microrm_library-1.3.6.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.6 Darwin/23.2.0

File hashes

Hashes for perseus_microrm_library-1.3.6.tar.gz
Algorithm Hash digest
SHA256 ad7f1aad85cce3afcc9e496f7219d81eea42d0dcc3e8e1505402336eb15062a6
MD5 70b4182121d3c63ff66f08656124db1b
BLAKE2b-256 6bedc30ef406f4997adca30ea54913db0e4edde2342dcba4bcc65dbcf2b846d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perseus_microrm_library-1.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 000901399a7f886225c3d10756bfd16be408cdccc0abfb4300bb7a8d37a5a713
MD5 df7aab6e68d2c04f0b7944b6783a31f9
BLAKE2b-256 e5e0c5ea0d7681e0a07c88a8b9da02e47e9dd9dcb99c54f4b14b5ceb0f484419

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