{ "info": { "author": "Lele Gaifax", "author_email": "lele@metapensiero.it", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Database" ], "description": ".. -*- coding: utf-8 -*-\n.. :Progetto: metapensiero.sqlalchemy.asyncio -- Asyncio middleware for SA\n.. :Creato: ven 10 lug 2015 10:48:44 CEST\n.. :Autore: Lele Gaifax \n.. :Licenza: GNU General Public License version 3 or later\n..\n\n=================================\n metapensiero.sqlalchemy.asyncio\n=================================\n\nA port of Alchimia_ to Python 3.4 asyncio\n=========================================\n\nThe aiopg_ and aiomysql_ projects allow to operate asynchronously with\nPostgresQL_ and MySQL_, respectively, even thru SQLAlchemy_. Their\napproach isn't ideal, though, because they reimplement a considerable\namount of SA low level stuff with undesirable glitches.\n\nThe Twisted_ based Alchimia_ way is much lighter and even if maybe\nslightly less performant it does not introduce unexpected surprises.\n\nUsage\n-----\n\nBasically the module wraps a minimal set of SA classes (currently just\n``Engine``, ``Connection``, ``Transaction`` and ``ResultProxy``) into\nasyncronous counterparts, and you work on them like the following\nexample::\n\n from asyncio import coroutine\n from metapensiero.sqlalchemy.asyncio import create_engine\n\n @coroutine\n def do_something(db_url):\n engine = create_engine(db_url)\n with (yield from engine.connect()) as conn:\n with (yield from conn.begin()) as trans:\n yield from conn.execute(users.insert()\n .values(id=42, name=\"Async\",))\n\n res = yield from conn.execute(users.select()\n .where(users.c.id == 42))\n rows = yield from res.fetchall()\n\n res = yield from conn.execute(users.delete()\n .where(users.c.id == 42))\n assert res.rowcount == 1\n\nIf you are using Python 3.5 or better, the above should be written as::\n\n from metapensiero.sqlalchemy.asyncio import create_engine\n\n async def do_something(db_url):\n engine = create_engine(db_url)\n async with await engine.connect() as conn:\n async with await conn.begin() as trans:\n await conn.execute(users.insert()\n .values(id=42, name=\"Async\",))\n\n res = await conn.execute(users.select()\n .where(users.c.id == 42))\n rows = await res.fetchall()\n\n res = await conn.execute(users.delete()\n .where(users.c.id == 42))\n assert res.rowcount == 1\n\nTests\n-----\n\nTo run the unit tests, you should:\n\na) create a Python virtual environment and install this package in\n development mode::\n\n python3 -m venv env\n source env/bin/activate\n python setup.py develop\n\nb) install ``pytest``, ``pytest-asyncio`` and either ``psycopg2-binary`` or ``pymysql``::\n\n pip install pytest pytest-asyncio psycopg2-binary pymysql\n\nc) create a test database, for example with ``createdb testdb``\n\nd) execute the ``py.test`` runner with an environment variable with\n the SA URL of the db::\n\n TEST_DB_URL=\"postgresql://localhost/testdb\" py.test tests\n TEST_DB_URL=\"mysql+pymysql://localhost/testdb\" py.test tests\n\n.. _aiomysql: https://github.com/aio-libs/aiomysql\n.. _aiopg: https://github.com/aio-libs/aiopg\n.. _alchimia: https://pypi.python.org/pypi/alchimia\n.. _mysql: http://www.mysql.com\n.. _postgresql: http://www.postgresql.org\n.. _sqlalchemy: http://www.sqlalchemy.org\n.. _twisted: https://twistedmatrix.com/\n\n\nChanges\n-------\n\n1.0 (2018-07-01)\n~~~~~~~~~~~~~~~~\n\n- Renamed to metapensiero.sqlalchemy.asyncio\n\n\n0.4 (2015-09-25)\n~~~~~~~~~~~~~~~~\n\n- Packaging tweaks\n\n\n0.3 (2015-09-23)\n~~~~~~~~~~~~~~~~\n\n- Support Python 3.5 asynchronous context managers\n\n\n0.2 (2015-09-09)\n~~~~~~~~~~~~~~~~\n\n- First (usable) distribution on PyPI\n\n\n0.1 (private)\n~~~~~~~~~~~~~\n\nWorks reasonably well!\n\n\n0.0 (private)\n~~~~~~~~~~~~~\n\nInitial effort.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/metapensiero/metapensiero.sqlalchemy.asyncio", "keywords": "asyncio sqlalchemy", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "metapensiero.sqlalchemy.asyncio", "package_url": "https://pypi.org/project/metapensiero.sqlalchemy.asyncio/", "platform": "", "project_url": "https://pypi.org/project/metapensiero.sqlalchemy.asyncio/", "project_urls": { "Homepage": "https://gitlab.com/metapensiero/metapensiero.sqlalchemy.asyncio" }, "release_url": "https://pypi.org/project/metapensiero.sqlalchemy.asyncio/1.0/", "requires_dist": null, "requires_python": "", "summary": "Asyncio middleware for SQLAlchemy", "version": "1.0" }, "last_serial": 4019890, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "690a670d7ece5f985ed0d9f63063e4bb", "sha256": "806b58f1b18ffe1d1836d06bde2472eae4f2dfa719195dac04875130a5431cee" }, "downloads": -1, "filename": "metapensiero.sqlalchemy.asyncio-1.0.tar.gz", "has_sig": false, "md5_digest": "690a670d7ece5f985ed0d9f63063e4bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6410, "upload_time": "2018-07-01T09:57:05", "url": "https://files.pythonhosted.org/packages/2e/1b/54ab947af9056d7c4307b9dcda4428e1f0db839a4a5eb02423d1b1323ec9/metapensiero.sqlalchemy.asyncio-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "690a670d7ece5f985ed0d9f63063e4bb", "sha256": "806b58f1b18ffe1d1836d06bde2472eae4f2dfa719195dac04875130a5431cee" }, "downloads": -1, "filename": "metapensiero.sqlalchemy.asyncio-1.0.tar.gz", "has_sig": false, "md5_digest": "690a670d7ece5f985ed0d9f63063e4bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6410, "upload_time": "2018-07-01T09:57:05", "url": "https://files.pythonhosted.org/packages/2e/1b/54ab947af9056d7c4307b9dcda4428e1f0db839a4a5eb02423d1b1323ec9/metapensiero.sqlalchemy.asyncio-1.0.tar.gz" } ] }