{ "info": { "author": "Andreas Runfalk", "author_email": "andreas@runfalk.se", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Database", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing", "Topic :: Software Development :: Testing :: Unit" ], "description": "TempDB\n======\nSpawn temporary PostgreSQL clusters for use in unit tests. This is alpha quality\nsoftware and the API may change between version.\n\n\nUsage\n-----\nThe following example shows how to create a temporary database with ``pytest``.\n\n.. code-block:: python\n\n import psycopg2\n import pytest\n\n from contextlib import closing\n from tempdb import find_postgres_bin_dir, PostgresFactory\n\n\n @pytest.fixture\n def conn():\n # Try to discover a directory where PostgreSQL is installed. If you\n # have installed it in a non-standard location you must replace\n # pg_bin_dir with the path to the binary directory for your\n # installation.\n #\n # It is possible to provide a specific version as an argument if there\n # are multiple versions to choose from. The highest available version\n # is chosen by default.\n pg_bin_dir = find_postgres_bin_dir()\n if pg_bin_dir is None:\n pytest.skip(\"Unable to locate a PostgreSQL installation\")\n\n # The factory is bound to a particular PostgreSQL version and can be\n # used to create an arbitrary number of clusters\n factory = PostgresFactory(pg_bin_dir)\n\n # A cluster is an actual running instance of PostgreSQL. By default a\n # cluster doesn't have any databases apart from the defaults. It is\n # possible to create new databases using the method\n # .create_database(name, template=None)\n with closing(factory.create_temporary_cluster()) as cluster:\n tmp_db = cluster.create_database(\"tmp\")\n yield psycopg2.connect(tmp_db.dsn)\n\n\n def test_create_tables(conn):\n with conn.cursor() as c:\n c.execute(\"\"\"\n CREATE TABLE test(\n id SERIAL,\n name VARCHAR\n )\n \"\"\")\n c.execute(\"INSERT INTO test(name) VALUES (%s), (%s)\", [\n \"Abel\",\n \"Cain\",\n ])\n c.execute(\"SELECT name FROM test ORDER BY id\")\n\n assert [name for name, in c.fetchall()] == [\n \"Abel\",\n \"Cain\",\n ]\n\n\nChangelog\n---------\n\nVersion 0.1.0\n~~~~~~~~~~~~~\nReleased on 3rd June, 2019\n\n- Initial release\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/runfalk/tempdb", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "tempdb", "package_url": "https://pypi.org/project/tempdb/", "platform": "", "project_url": "https://pypi.org/project/tempdb/", "project_urls": { "Homepage": "https://github.com/runfalk/tempdb" }, "release_url": "https://pypi.org/project/tempdb/0.1.0/", "requires_dist": [ "psycopg2-binary (>=2.5)", "pytest (>=3) ; extra == 'dev'" ], "requires_python": "", "summary": "Create temporary databases for testing.", "version": "0.1.0" }, "last_serial": 5353973, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d59c23dd124ba002a2cef9029b8f6705", "sha256": "d3f3b584289e2d8a54477bd0979cf77ce1057306770696ec5166e5d2a86a7e05" }, "downloads": -1, "filename": "tempdb-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d59c23dd124ba002a2cef9029b8f6705", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9391, "upload_time": "2019-06-03T18:51:54", "url": "https://files.pythonhosted.org/packages/ee/7a/1b16bf794cfd44014dac8256b357a26148dcc7d06b03a04c04ac058c9a71/tempdb-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ab376eec80671c5b581821c6cb848a5f", "sha256": "d28727726ffd319fe3f32ef766fbae27d2ae5902ffa85e4a981d1f06ed89dc75" }, "downloads": -1, "filename": "tempdb-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ab376eec80671c5b581821c6cb848a5f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10036, "upload_time": "2019-06-03T18:51:57", "url": "https://files.pythonhosted.org/packages/8b/89/cb7dda989052a8b1ec8fa1e9d8841632757e77ac3cd166efb78a9e7c3eb9/tempdb-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d59c23dd124ba002a2cef9029b8f6705", "sha256": "d3f3b584289e2d8a54477bd0979cf77ce1057306770696ec5166e5d2a86a7e05" }, "downloads": -1, "filename": "tempdb-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d59c23dd124ba002a2cef9029b8f6705", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9391, "upload_time": "2019-06-03T18:51:54", "url": "https://files.pythonhosted.org/packages/ee/7a/1b16bf794cfd44014dac8256b357a26148dcc7d06b03a04c04ac058c9a71/tempdb-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ab376eec80671c5b581821c6cb848a5f", "sha256": "d28727726ffd319fe3f32ef766fbae27d2ae5902ffa85e4a981d1f06ed89dc75" }, "downloads": -1, "filename": "tempdb-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ab376eec80671c5b581821c6cb848a5f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10036, "upload_time": "2019-06-03T18:51:57", "url": "https://files.pythonhosted.org/packages/8b/89/cb7dda989052a8b1ec8fa1e9d8841632757e77ac3cd166efb78a9e7c3eb9/tempdb-0.1.0.tar.gz" } ] }