# 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](https://github.com/dcaune/perseus-microrm-python-library), simply enter the follow command line:
``` shell
pip install perseus-microrm-library
```
## Usage
``` python
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)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/majormode/perseus-microrm-python-library",
"name": "perseus-microrm-library",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "micro,orm,libray,postgresql,rdbms",
"author": "Daniel CAUNE",
"author_email": "daniel.caune@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/21/22/7307c8c2651268c2c5db1508c3520f4828387890cff3ea2299341bc53e93/perseus_microrm_library-1.3.8.tar.gz",
"platform": null,
"description": "# Perseus MicrORM\n\nMajormode Perseus MicrORM Python Library is a small, little, mini, tiny, micro Object-Relational Mapping (ORM).\n\nMicrORM 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.\n\n## Installation\n\nTo install [Perseus MicrORM Python Library](https://github.com/dcaune/perseus-microrm-python-library), simply enter the follow command line:\n\n``` shell\npip install perseus-microrm-library\n```\n\n## Usage\n\n``` python\nimport uuid\n\nfrom majormode.perseus.utils import cast\nfrom majormode.perseus.utils.rdbms import RdbmsConnection\n\n\nRDBMS_CONNECTION_PROPERTIES = {\n None: {\n 'rdbms_hostname': 'localhost',\n 'rdbms_port': 5432,\n 'rdbms_database_name': 'foo',\n 'rdbms_account_username': 'dbo',\n 'rdbms_account_password': ''\n }\n}\n\nPLACE_IDS = [\n uuid.UUID('54879ffc-a1ec-11e8-85bd-0008a20c190f'),\n uuid.UUID('9025d1c8-a1ec-11e8-9e29-0007cb040bcc')\n]\n\nwith RdbmsConnection.acquire_connection(\n RDBMS_CONNECTION_PROPERTIES,\n auto_commit=False,\n connection=None) as connection:\n cursor = connection.execute(\n \"\"\"\n SELECT place_id,\n ST_X(location) AS longitude,\n ST_Y(location) AS latitude,\n ST_Z(location) AS altitude,\n accuracy,\n creation_time\n FROM place\n WHERE place_id IN %[place_ids]s\n \"\"\",\n {\n 'place_ids': PLACE_IDS \n })\n rows = cursor.fetch_all()\n\n places = [\n row.get_object({\n 'place_id': cast.string_to_uuid,\n 'creation_time': cast.string_to_timestamp})\n for row in cursor.fetch_all()]\n\n for place in places:\n print(place.place_id, place.longitude, place.latitude)\n```\n",
"bugtrack_url": null,
"license": "SEE LICENSE IN <LICENSE.md>",
"summary": "Python small, little, mini, tiny, micro Object-Relational Mapping (ORM)",
"version": "1.3.8",
"project_urls": {
"Homepage": "https://github.com/majormode/perseus-microrm-python-library",
"Repository": "https://github.com/majormode/perseus-microrm-python-library"
},
"split_keywords": [
"micro",
"orm",
"libray",
"postgresql",
"rdbms"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a2539487bbd318960e4bee12da48fab52443e467c35d6ccfa9f797389553823f",
"md5": "3696bae43813eb1ec0bc069fb1cd843a",
"sha256": "3924051ccee44c25993f5058de324f311d55a829c306e70fd1fb2245ca2af0a3"
},
"downloads": -1,
"filename": "perseus_microrm_library-1.3.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3696bae43813eb1ec0bc069fb1cd843a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 14855,
"upload_time": "2024-02-26T09:14:33",
"upload_time_iso_8601": "2024-02-26T09:14:33.945550Z",
"url": "https://files.pythonhosted.org/packages/a2/53/9487bbd318960e4bee12da48fab52443e467c35d6ccfa9f797389553823f/perseus_microrm_library-1.3.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "21227307c8c2651268c2c5db1508c3520f4828387890cff3ea2299341bc53e93",
"md5": "88bd54d9917981c1aa5cf1c66d2c87f0",
"sha256": "71888eb8d0eac09ad57910528ad60aa6e7103185be6530facf93d04eb67e37a9"
},
"downloads": -1,
"filename": "perseus_microrm_library-1.3.8.tar.gz",
"has_sig": false,
"md5_digest": "88bd54d9917981c1aa5cf1c66d2c87f0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 11141,
"upload_time": "2024-02-26T09:14:35",
"upload_time_iso_8601": "2024-02-26T09:14:35.907710Z",
"url": "https://files.pythonhosted.org/packages/21/22/7307c8c2651268c2c5db1508c3520f4828387890cff3ea2299341bc53e93/perseus_microrm_library-1.3.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-26 09:14:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "majormode",
"github_project": "perseus-microrm-python-library",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "perseus-microrm-library"
}