=================
sqlalchemy-things
=================
|ReadTheDocs| |PyPI release| |License| |Python versions| |PyPI downloads| |GitHub CI| |Codecov|
.. |ReadTheDocs| image:: https://readthedocs.org/projects/sqlalchemy-things/badge/?version=latest
:target: https://sqlalchemy-things.readthedocs.io/en/latest/?badge=latest
:alt: Read The Docs build
.. |PyPI release| image:: https://badge.fury.io/py/sqlalchemy-things.svg
:target: https://pypi.org/project/sqlalchemy-things/
:alt: Release
.. |License| image:: https://img.shields.io/badge/License-MIT-green
:target: https://github.com/ri-gilfanov/sqlalchemy-things/blob/master/LICENSE
:alt: MIT License
.. |Python versions| image:: https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue
:target: https://pypi.org/project/sqlalchemy-things/
:alt: Python version support
.. |PyPI downloads| image:: https://static.pepy.tech/personalized-badge/sqlalchemy-things?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads
:target: https://pepy.tech/project/sqlalchemy-things
:alt: PyPI downloads count
.. |GitHub CI| image:: https://github.com/ri-gilfanov/sqlalchemy-things/actions/workflows/ci.yml/badge.svg?branch=master
:target: https://github.com/ri-gilfanov/sqlalchemy-things/actions/workflows/ci.yml
:alt: GitHub continuous integration
.. |Codecov| image:: https://codecov.io/gh/ri-gilfanov/sqlalchemy-things/branch/master/graph/badge.svg
:target: https://codecov.io/gh/ri-gilfanov/sqlalchemy-things
:alt: codecov.io status for master branch
Utility collection for development with `SQLAlchemy 2.0
<https://www.sqlalchemy.org/>`_ ORM.
Documentation
-------------
https://sqlalchemy-things.readthedocs.io
Installation
------------
Installing ``sqlalchemy-things`` with pip: ::
pip install sqlalchemy-things
Examples
--------
Single table inheritance
^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
from sqlalchemy import orm
from sqlalchemy_things.declarative import (
IntegerPrimaryKeyMixin,
PolymorphicMixin,
)
class Base(orm.DeclarativeBase): ...
class ParentA(Base, IntegerPrimaryKeyMixin, PolymorphicMixin):
__tablename__ = "single_table"
class ChildA1(ParentA):
__mapper_args__ = {"polymorphic_identity": "child_a1"}
some_field = sa.Column(sa.String(255))
class ChildA2(ParentA):
__mapper_args__ = {"polymorphic_identity": "child_a2"}
other_filed = sa.Column(sa.String(127))
Joined table inheritance with cascade primary key mixins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
from sqlalchemy import orm
from sqlalchemy_things.declarative import (
CascadeIntegerPrimaryKeyMixin,
PolymorphicMixin,
)
class Base(orm.DeclarativeBase): ...
class ParentB(Base, CascadeIntegerPrimaryKeyMixin, PolymorphicMixin):
__tablename__ = "parent_b"
class ChildB1(ParentB):
__tablename__ = "child_b1"
__mapper_args__ = {"polymorphic_identity": "child_b1"}
some_field = sa.Column(sa.String(255))
class ChildB2(ParentB):
__tablename__ = "child_b2"
__mapper_args__ = {"polymorphic_identity": "child_b2"}
some_field = sa.Column(sa.String(127))
Joined table inheritance with simple primary key mixins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
from sqlalchemy import orm
from sqlalchemy_things.declarative import (
IntegerPrimaryKeyMixin,
ParentPrimaryKeyMixin,
PolymorphicMixin,
)
class Base(orm.DeclarativeBase): ...
class ParentC(Base, IntegerPrimaryKeyMixin, PolymorphicMixin):
__tablename__ = "parent_c"
class ChildC1(ParentPrimaryKeyMixin, ParentC):
__tablename__ = "child_c1"
__mapper_args__ = {"polymorphic_identity": "child_c1"}
some_field = sa.Column(sa.String(255))
class ChildC2(ParentPrimaryKeyMixin, ParentC):
__tablename__ = "child_c2"
__mapper_args__ = {"polymorphic_identity": "child_c2"}
some_field = sa.Column(sa.String(127))
Raw data
{
"_id": null,
"home_page": "https://github.com/ri-gilfanov/sqlalchemy-things",
"name": "sqlalchemy-things",
"maintainer": "Ruslan Ilyasovich Gilfanov",
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": "ri.gilfanov@yandex.ru",
"keywords": "sqlalchemy",
"author": "Ruslan Ilyasovich Gilfanov",
"author_email": "ri.gilfanov@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/8d/79/e776b234dbad34570b023208ac85c503a0ab385a236276bbf33c0a23fd13/sqlalchemy_things-1.0.1.tar.gz",
"platform": null,
"description": "=================\nsqlalchemy-things\n=================\n|ReadTheDocs| |PyPI release| |License| |Python versions| |PyPI downloads| |GitHub CI| |Codecov|\n\n.. |ReadTheDocs| image:: https://readthedocs.org/projects/sqlalchemy-things/badge/?version=latest\n :target: https://sqlalchemy-things.readthedocs.io/en/latest/?badge=latest\n :alt: Read The Docs build\n\n.. |PyPI release| image:: https://badge.fury.io/py/sqlalchemy-things.svg\n :target: https://pypi.org/project/sqlalchemy-things/\n :alt: Release\n\n.. |License| image:: https://img.shields.io/badge/License-MIT-green\n :target: https://github.com/ri-gilfanov/sqlalchemy-things/blob/master/LICENSE\n :alt: MIT License\n\n.. |Python versions| image:: https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue\n :target: https://pypi.org/project/sqlalchemy-things/\n :alt: Python version support\n\n.. |PyPI downloads| image:: https://static.pepy.tech/personalized-badge/sqlalchemy-things?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads\n :target: https://pepy.tech/project/sqlalchemy-things\n :alt: PyPI downloads count\n\n.. |GitHub CI| image:: https://github.com/ri-gilfanov/sqlalchemy-things/actions/workflows/ci.yml/badge.svg?branch=master\n :target: https://github.com/ri-gilfanov/sqlalchemy-things/actions/workflows/ci.yml\n :alt: GitHub continuous integration\n\n.. |Codecov| image:: https://codecov.io/gh/ri-gilfanov/sqlalchemy-things/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/ri-gilfanov/sqlalchemy-things\n :alt: codecov.io status for master branch\n\nUtility collection for development with `SQLAlchemy 2.0\n<https://www.sqlalchemy.org/>`_ ORM.\n\nDocumentation\n-------------\nhttps://sqlalchemy-things.readthedocs.io\n\nInstallation\n------------\nInstalling ``sqlalchemy-things`` with pip: ::\n\n pip install sqlalchemy-things\n\nExamples\n--------\nSingle table inheritance\n^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: python\n\n from sqlalchemy import orm\n from sqlalchemy_things.declarative import (\n IntegerPrimaryKeyMixin,\n PolymorphicMixin,\n )\n\n class Base(orm.DeclarativeBase): ...\n\n\n class ParentA(Base, IntegerPrimaryKeyMixin, PolymorphicMixin):\n __tablename__ = \"single_table\"\n\n\n class ChildA1(ParentA):\n __mapper_args__ = {\"polymorphic_identity\": \"child_a1\"}\n some_field = sa.Column(sa.String(255))\n\n\n class ChildA2(ParentA):\n __mapper_args__ = {\"polymorphic_identity\": \"child_a2\"}\n other_filed = sa.Column(sa.String(127))\n\nJoined table inheritance with cascade primary key mixins\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: python\n\n from sqlalchemy import orm\n from sqlalchemy_things.declarative import (\n CascadeIntegerPrimaryKeyMixin,\n PolymorphicMixin,\n )\n\n class Base(orm.DeclarativeBase): ...\n\n\n class ParentB(Base, CascadeIntegerPrimaryKeyMixin, PolymorphicMixin):\n __tablename__ = \"parent_b\"\n\n\n class ChildB1(ParentB):\n __tablename__ = \"child_b1\"\n __mapper_args__ = {\"polymorphic_identity\": \"child_b1\"}\n some_field = sa.Column(sa.String(255))\n\n\n class ChildB2(ParentB):\n __tablename__ = \"child_b2\"\n __mapper_args__ = {\"polymorphic_identity\": \"child_b2\"}\n some_field = sa.Column(sa.String(127))\n\n\nJoined table inheritance with simple primary key mixins\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: python\n\n from sqlalchemy import orm\n from sqlalchemy_things.declarative import (\n IntegerPrimaryKeyMixin,\n ParentPrimaryKeyMixin,\n PolymorphicMixin,\n )\n\n class Base(orm.DeclarativeBase): ...\n\n\n class ParentC(Base, IntegerPrimaryKeyMixin, PolymorphicMixin):\n __tablename__ = \"parent_c\"\n\n\n class ChildC1(ParentPrimaryKeyMixin, ParentC):\n __tablename__ = \"child_c1\"\n __mapper_args__ = {\"polymorphic_identity\": \"child_c1\"}\n some_field = sa.Column(sa.String(255))\n\n\n class ChildC2(ParentPrimaryKeyMixin, ParentC):\n __tablename__ = \"child_c2\"\n __mapper_args__ = {\"polymorphic_identity\": \"child_c2\"}\n some_field = sa.Column(sa.String(127))\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utility collection for development with SQLalchemy ORM.",
"version": "1.0.1",
"project_urls": {
"Documentation": "https://sqlalchemy-things.readthedocs.io/",
"Homepage": "https://github.com/ri-gilfanov/sqlalchemy-things",
"Repository": "https://github.com/ri-gilfanov/sqlalchemy-things"
},
"split_keywords": [
"sqlalchemy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ad0eff2bcf26a57f8bb34a1136c6a7350abc378c02143bce65f886479cec1bb6",
"md5": "7ed391272f45226c64567f003a72c360",
"sha256": "e2380892e0d809ffeb0677d4543008f38079c04581ded04251e12a3c302dd673"
},
"downloads": -1,
"filename": "sqlalchemy_things-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7ed391272f45226c64567f003a72c360",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 7788,
"upload_time": "2024-09-16T19:40:57",
"upload_time_iso_8601": "2024-09-16T19:40:57.507741Z",
"url": "https://files.pythonhosted.org/packages/ad/0e/ff2bcf26a57f8bb34a1136c6a7350abc378c02143bce65f886479cec1bb6/sqlalchemy_things-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8d79e776b234dbad34570b023208ac85c503a0ab385a236276bbf33c0a23fd13",
"md5": "0d378e367438bb7ee30c1b78c823365c",
"sha256": "1668c1a29361cf29120625c30cdb5472ac491f4fe07b976d73be3826518af3e2"
},
"downloads": -1,
"filename": "sqlalchemy_things-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "0d378e367438bb7ee30c1b78c823365c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 6933,
"upload_time": "2024-09-16T19:40:58",
"upload_time_iso_8601": "2024-09-16T19:40:58.866282Z",
"url": "https://files.pythonhosted.org/packages/8d/79/e776b234dbad34570b023208ac85c503a0ab385a236276bbf33c0a23fd13/sqlalchemy_things-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-16 19:40:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ri-gilfanov",
"github_project": "sqlalchemy-things",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sqlalchemy-things"
}