{ "info": { "author": "Inpool", "author_email": "inpool@126.com", "bugtrack_url": null, "classifiers": [ "Framework :: Pyramid", "Programming Language :: Python", "Topic :: Database", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application" ], "description": "==========================\nPyramid_peewee_conn README\n==========================\n\nOverview\n==========\n\nA package which provides integration between the Pyramid web application server and \nthe peewee ORM.\n\nIt's tested under CPython 3.4 but maybe run under any environ which pyramid and peewee can be used.\nIf you found any issue in using it, please `submit it `_.\n\nInstallation\n============\n\nInstall using setuptools, e.g. (within a virtual environment)::\n\n $ easy_install pyramid_peewee_conn\n\nOr using pip::\n\n $ pip install pyramid_peewee_conn\n\nOr install from github::\n\n $ git clone https://github.com/inpool/pyramid_peewee_conn\n $ cd pyramid_peewee_conn\n $ python setup.py install\n\nOr if your computer hasn't git command, you can install it via from github::\n\n $ pip install https://github.com/inpool/pyramid_peewee_conn/archive/master.zip\n\nSetup\n=======\n\nOnce ``pyramid_peewee_conn`` is installed, you must use the ``config.include``\nmechanism to include it into your Pyramid project's configuration. In your\nPyramid project's ``__init__.py``:\n\n.. code-block:: python\n\n config = Configurator(.....)\n config.include('pyramid_peewee_conn')\n\nAlternately you can use the ``pyramid.includes`` configuration value in your\n``.ini`` file:\n\n.. code-block:: ini\n\n [app:myapp]\n pyramid.includes = pyramid_peewee_conn\n\nUsing\n=======\n\nFor ``pyramid_peewee_conn`` to work properly, you must add at least one\nsetting to your of your Pyramid's ``.ini`` file configuration (or to the\n``settings`` dictionary if you're not using ini configuration):\n``peewee.urls``. For example:\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n peewee.url = postgres://username:password@hostname:port/database_name\n # ...\n\nThe ``peewee.url`` parameter is a URL defined in the peewee documentation\n`Connecting using a Database URL `_ \n\nOnce you've both included the ``pyramid_peewee_conn`` into your configuration\nvia ``config.include('pyramid_peewee_conn')`` and you've added a\n``peewee.url`` setting to your configuration, you can then use the\n``pyramid_peewee_conn.get_db()`` API in your Pyramid application, most\ncommonly in a model defintion:\n\n.. code-block:: python\n\n from peewee import *\n from pyramid_peewee_conn import get_db\n \n db = get_db()\n\n class Person(Model):\n name = CharField()\n age = IntegerField()\n\n class Meta:\n database = db\n\n class Pet(Model)\n name = CharField()\n owner = ForeignKeyField(Person, related_name='pets')\n animal_type = CharField()\n\n db.connect()\n db.create_tables([Person, Pet])\n\nThe ``pyramid_peewee_conn.get_db()`` API returns a peewee.Database instance which \nyou've specified via ``peewee.url`` in your configuration.\n\n\nAttention\n==========\n\nSince the peewee database url is configure in ini file, the API ``pyramid_peewee_conn.get_db()`` \nmust use after the instance of ``pyramid.config.Configurator`` has been created and this package \nhas been included. In other words, if you configure this package via ini file like this:\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n pyramid.includes = pyramid_peewee_conn\n # ...\n\nYou can use ``pyramid_peewee_conn.get_db()`` after the instance of ``pyramid.config.Configurator``\nhas been created. if you configure this package imperatively, you must use ``pyramid_peewee_conn.get_db()``\nafter the ``pyramid.config.Configurator.include()`` method has called by pass `'pyramid_peewee_conn'`.\n\n.. code-block:: python\n\n from pyramid.config import Configurator\n\n def main(global_config, **settings):\n config = Configurator(settings=settings)\n # Now you can use get_db() if you configure this package in ini file.\n config.include('pyramid_peewee_conn')\n # Or you can use get_db() at this time.\n\n\nDelay Initializtion\n====================\n\nThere are some cases that need use the database before the ``pyramid.config.Configurator`` has\nbeen instantiated. For example, a Model class is the configurator's root_factory, or by any\nreason of, you need import the models in the `__init__.py` file.\n\nIn these cases, you can use ``pyramid_peewee_conn.get_proxy()`` instead of\n``pyramid_peewee_conn.get_db()``, the parameters of ``get_proxy()`` is as same as ``get_db()``.\n\nThe ``pyramid_peewee_conn.get_proxy()`` returns an ``peewee.Proxy`` instance which will initialize\nautomatically at that time when ``pyramid.config.Configurator`` include this package.\n\nNow, you can use peewee database before the ``pyramid.config.Configurator`` has been instantiated.\nBut you can't do any database opration before ``pyramid.config.Configurator`` has been instantiated.\n\n.. note::\n \n The proxy which ``pyramid_peewee_conn.get_proxy()`` will never initialize except this package\n was included next time or call ``pyramid_peewee_conn.init_proxies()`` explicit. You can get more\n information in the API's docstring.\n\nNamed Databases\n===============\n\nIf you need to use more than one database in your Pyramid application,\nyou can use *named* databases via configuration. Named databases are\nspecified by ``peewee.url.thename`` in settings configuration. For\nexample:\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n peewee.url = postgres://username:password@hostname:port/database_name\n peewee.url.memory = sqlite:///:memory:\n # ...\n\nOnce this is done, you can use ``pyramid_peewee_conn.get_db()`` to\nobtain a reference to each of the named databases:\n\n.. code-block:: python\n\n db = get_db() # main database\n memory_db = get_db('memory')\n\nThe ``peewee.url.memory`` parameter example above is a URL which\ndescribes peewee database, in the same format as ``peewee.url``. You can\ncombine named and unnamed database configuration in the same application.\nYou can also use named databases without a main database.\n\nAnother config format\n======================\n\nPerhaps you had used pyramid_peewee, which config ``peewee.urls`` in the ini configure file like this:\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n peewee.urls = postgres://username:password@hostname:port/database_1\n sqlite:///test.db\n # ...\n\nThis config format is supported. In this case, the database name is the database name.\nThe prior configuration is equal to the next:\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n peewee.url = postgres://username:password@hostname:port/database_1\n peewee.url.database_1 = postgres://username:password@hostname:port/database_1\n peewee.url.test.db = sqlite:///test.db\n # ...\n\nAPIs\n=======\n\nThis package offer three API:\n\n- pyramid_peewee_conn.get_db()\n- pyramid_peewee_conn.get_proxy()\n- pyramid_peewee_conn.init_proxies()\n\nThe usage of these function you can found in there own's docstring via builtin ``help(obj)``.\n\nIf you found there were more functions or classes else in the souce code, it maybe changed in future.\n\nConflict\n==========\n\nOnce there are both two format configure and have some database conflict, \nthe explicit configuration will be used.\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n peewee.url = postgres://user:pass@host:port/database\n peewee.url.db1 = mysql://user:pass@host:port/database\n peewee.urls = \n mysql://user:pass@host:port/db1\n postgres://user:pass@host:port/database\n # ...\n\nThe prior configuration is equal next:\n\n.. code-block:: ini\n\n [app:myapp]\n # ...\n peewee.url = postgres://user:pass@host:port/database\n peewee.url.db1 = mysql://user:pass@host:port/database\n peewee.url.database = postgres://user:pass@host:port/database\n # ...\n\nChange Log\n=============\n\n0.7.1\n------\n\nJust change the description.\n\n0.7.0\n------\n\n- Add API ``get_proxy()`` and it's documentation\n- Add API ``init_proxies()`` and it's documentation\n- Add unit test for the new APIs\n\n0.6.3\n------\n\nFix a bug with old_style database urls.\n\n0.6.2\n------\n\nFix formats of README and Changelog.\n\n0.6.1\n------\n\nComplete unit test.\n \n- Unit test each API separate into 3 cases.\n- Add multiple installation methods in README.rst\n- Fix bug when include more than once(Offen in unit test).\n\n\n0.6.0\n------\n\n- Add unit test.\n- Fix\n\n0.5.2\n------\n\n- Fix. Report a CHANGES.txt can't be found error.\n\n0.5.1\n------\n\n- Fix. README.rst has some format error.\n\n0.1.0\n------\n\n- Initial version", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/inpool/pyramid_peewee_conn", "keywords": "web pyramid peewee", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyramid-peewee-conn", "package_url": "https://pypi.org/project/pyramid-peewee-conn/", "platform": "", "project_url": "https://pypi.org/project/pyramid-peewee-conn/", "project_urls": { "Homepage": "https://github.com/inpool/pyramid_peewee_conn" }, "release_url": "https://pypi.org/project/pyramid-peewee-conn/0.7.1/", "requires_dist": null, "requires_python": "", "summary": "Provides integration between the Pyramid and the Peewee imitate pyramid_zodbconn's API", "version": "0.7.1" }, "last_serial": 3239599, "releases": { "0.7.0": [ { "comment_text": "", "digests": { "md5": "c9ff64d39061c08ac66dd482df67d878", "sha256": "d1d0a44a51cdd12f5540f8cd19613466238dd670e02a91560a52754de9f43378" }, "downloads": -1, "filename": "pyramid_peewee_conn-0.7.0.tar.gz", "has_sig": false, "md5_digest": "c9ff64d39061c08ac66dd482df67d878", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6559, "upload_time": "2017-10-09T01:19:57", "url": "https://files.pythonhosted.org/packages/9c/b1/6d2bdba823d90ba5ed187806857762e4ad6320533eb8c705200dae65beb0/pyramid_peewee_conn-0.7.0.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "bf887c496975eb383953f65b0559ae68", "sha256": "ff7b209724c0e0d8efe9beafed28865738c5af78e47f77d601db8b8efb694ab8" }, "downloads": -1, "filename": "pyramid_peewee_conn-0.7.1.tar.gz", "has_sig": false, "md5_digest": "bf887c496975eb383953f65b0559ae68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6593, "upload_time": "2017-10-09T01:28:57", "url": "https://files.pythonhosted.org/packages/d9/54/1bef98ffaf034e858a32928d79d10e9524becc0bf1ea9d646db4a93ac984/pyramid_peewee_conn-0.7.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bf887c496975eb383953f65b0559ae68", "sha256": "ff7b209724c0e0d8efe9beafed28865738c5af78e47f77d601db8b8efb694ab8" }, "downloads": -1, "filename": "pyramid_peewee_conn-0.7.1.tar.gz", "has_sig": false, "md5_digest": "bf887c496975eb383953f65b0559ae68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6593, "upload_time": "2017-10-09T01:28:57", "url": "https://files.pythonhosted.org/packages/d9/54/1bef98ffaf034e858a32928d79d10e9524becc0bf1ea9d646db4a93ac984/pyramid_peewee_conn-0.7.1.tar.gz" } ] }