# 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": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "micro, orm, libray, postgresql, rdbms",
"author": "Daniel CAUNE",
"author_email": "daniel.caune@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/25/aa/e66cdb4ef4cde3d45ecce3febb94d5d4caa5d2e64f25971418b05908655b/perseus_microrm_library-1.3.9.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.9",
"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": "0bba2daaaf657987a28b870ae85d2bdccaee5868bb5ba790e33b69ecdcfd197e",
"md5": "0b91f67da40ced05a53ffe530f8b2c86",
"sha256": "5c9e6283b31fe75ff42cf7bb4d586770828536fa9b90f0462b23dd461e495ece"
},
"downloads": -1,
"filename": "perseus_microrm_library-1.3.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0b91f67da40ced05a53ffe530f8b2c86",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 14863,
"upload_time": "2024-06-28T09:16:32",
"upload_time_iso_8601": "2024-06-28T09:16:32.547491Z",
"url": "https://files.pythonhosted.org/packages/0b/ba/2daaaf657987a28b870ae85d2bdccaee5868bb5ba790e33b69ecdcfd197e/perseus_microrm_library-1.3.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "25aae66cdb4ef4cde3d45ecce3febb94d5d4caa5d2e64f25971418b05908655b",
"md5": "9e52ecfdc59fda2ce24a28eefb83b651",
"sha256": "52f88046785f1664d620bf85dce6a09587f4b4d5a013be78ed5b2d0b8bf3a6ac"
},
"downloads": -1,
"filename": "perseus_microrm_library-1.3.9.tar.gz",
"has_sig": false,
"md5_digest": "9e52ecfdc59fda2ce24a28eefb83b651",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 11169,
"upload_time": "2024-06-28T09:16:34",
"upload_time_iso_8601": "2024-06-28T09:16:34.380803Z",
"url": "https://files.pythonhosted.org/packages/25/aa/e66cdb4ef4cde3d45ecce3febb94d5d4caa5d2e64f25971418b05908655b/perseus_microrm_library-1.3.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-28 09:16:34",
"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"
}