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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for perseus-microrm-library-1.3.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d20d5676d51e5f7e84f3d8c38a33a4dfb41cc468d40114c64e7822de4e7e16b |
|
MD5 | 5135b1fc3400dcc3126f1e7097fb3089 |
|
BLAKE2b-256 | f11f1a9212fe03abe6e6cdf78ea35d3f6760f44417c22098f579b989de93238d |
Close
Hashes for perseus_microrm_library-1.3.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82c58625887844a54699aef891f6ff58fe80f6dfff3b64caec8409bf12c675da |
|
MD5 | f6a6feb447191f28703a2e98bdca19dc |
|
BLAKE2b-256 | f49853e6c649e7e2b76d518afe64f540a5e15e6820e20c3bd597632e14193147 |