{ "info": { "author": "Jose Galvez", "author_email": "jose@cybergalvez.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Pyramid", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Database" ], "description": "**pyramid\\_peewee**\r\n===================\r\n\r\nPyramid\\_peewee is a module for the Pyramid web application framework\r\nwhich allos developers to use Peewee as their ORM.\r\n\r\nRequirements:\r\n\r\n::\r\n\r\n 1. Pyramid\r\n 2. Peewee\r\n 3. Database\r\n\r\nUsage:\r\n------\r\n\r\nTypically Pyramid based applications are configured in two locations, at\r\nthe application level within the application \\_\\_init\\_\\_.py file and at\r\nthe instance level within an \u201cini\u201d file, such as production.ini. To\r\nconfigure your applicaiton, first at the instance (eg production.ini)\r\nlevel you must set peewee.urls = \"database connection url\"\r\n\r\n.. code:: ini\r\n\r\n peewee.urls = sqlite:///dbase.db\r\n or\r\n peewee.urls = \r\n postgresql://user:pass@localhost:5432/mydatabase\r\n sqlite:///dbase.db\r\n\r\nNote we specifically use database urls as defined in the peewee\r\ndocumentation `Connecting using a Database\r\nURL `__\r\nand that you may specify as many database urls as your application needs\r\nwithin the peewee.urls paramter. At the application level, eg within\r\nyour applications \\_\\_init\\_\\_.py file\r\n\r\n1. import your database model\r\n2. include the command config.include('pyramid\\_peewee') within the\r\n config section.\r\n\r\nDefine your data model: To define your data model fist set your database\r\n= peewee.Proxy. Note if your database contains a \".\" in the name, such\r\nas with sqlite files replace it with an \"\\_\" (underscore).\r\n\r\n.. code:: python\r\n\r\n from peewee import *\r\n\r\n mydatabase = Proxy()\r\n dbase_db = Proxy()\r\n\r\n class People(Model):\r\n name = TextField()\r\n class Meta:\r\n database = mydatabase\r\n\r\n class Cars(model):\r\n name = TextField()\r\n class Meta:\r\n database = dbase_db\r\n\r\nIn this example we've defined two tables, each derived from different\r\ndatabase Proxies. Peewee allows you to define as many database\r\nconnections as you need and utilize them seemlessly within an\r\napplication.\r\n\r\nUsing your datamodel within a View:\r\n-----------------------------------\r\n\r\nTo utilize your datamodel within a view you must first get a datbase\r\nconnection. This is accomplished by calling the database proxy which is\r\ntied to the view request. By doing so database connections are properly\r\nclosed as the end of the request.\r\n\r\n.. code:: python\r\n\r\n from model import *\r\n def myView(requset):\r\n request.mydatabase\r\n joe = People.select().where(People.name=='joe').get()\r\n return dict(name=joe.name)\r\n\r\nAs stated above by calling request.mydatabase two things are\r\naccomplished, one a database connection is opened for the request, and\r\ntwo a callback is registered wich will properly close the connection at\r\nthe end of the request. Trying to use the model without first calling\r\nthe database method from the request object will result in an\r\nDataBaseClosed error. This is a devation from the normal PeeWee behavior\r\nwhich normaly opens a connection as needed.\r\n\r\nSupported database urls from the PeeWee documentation:\r\n------------------------------------------------------\r\n\r\n1. *sqlite:///my\\_database.db* will create a SqliteDatabase instance for\r\n the file my\\_database.db in the current directory.\r\n\r\n2. *sqlite:///:memory:* will create an in-memory SqliteDatabase\r\n instance.\r\n\r\n3. *postgresql://postgres:my\\_password@localhost:5432/my\\_database* will\r\n create a PostgresqlDatabase instance. A username and password are\r\n provided, as well as the host and port to connect to.\r\n\r\n4. *mysql://user:passwd@ip:port/my\\_db* will create a MySQLDatabase\r\n instance for the local MySQL database *my\\_db*.\r\n\r\nSupported schemes:\r\n\r\n1. apsw: APSWDatabase\r\n\r\n2. mysql: MySQLDatabase\r\n\r\n3. mysql+pool: PooledMySQLDatabase\r\n\r\n4. postgres: PostgresqlDatabase\r\n\r\n5. postgres+pool: PooledPostgresqlDatabase\r\n\r\n6. postgresext: PostgresqlExtDatabase\r\n\r\n7. postgresext+pool: PooledPostgresqlExtDatabase\r\n\r\n8. sqlite: SqliteDatabase\r\n\r\n9. sqliteext: SqliteExtDatabase\r\n\r\nThe most up to date documentation can always be found on their website:\r\n`Peewee Database\r\nURL `__", "description_content_type": null, "docs_url": null, "download_url": "https://bitbucket.org/jjgalvez/pyramid_peewee/get/0.5.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/jjgalvez/pyramid_peewee", "keywords": "web pyramid pylons database peewee", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pyramid_peewee", "package_url": "https://pypi.org/project/pyramid_peewee/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyramid_peewee/", "project_urls": { "Download": "https://bitbucket.org/jjgalvez/pyramid_peewee/get/0.5.zip", "Homepage": "https://bitbucket.org/jjgalvez/pyramid_peewee" }, "release_url": "https://pypi.org/project/pyramid_peewee/0.5/", "requires_dist": null, "requires_python": null, "summary": "Utilize Peewee as your ORM with Pyramid webapplications. - pyramid_peewee", "version": "0.5" }, "last_serial": 1664651, "releases": { "0.5": [ { "comment_text": "", "digests": { "md5": "9f6cfe1888c5d49a95692c1513ad1bc9", "sha256": "9c3adf6e7c4bbffb99485142209314f2e3d19da09b4572f7cd4a816e463304a5" }, "downloads": -1, "filename": "pyramid_peewee-0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "9f6cfe1888c5d49a95692c1513ad1bc9", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 8151, "upload_time": "2015-08-05T01:03:56", "url": "https://files.pythonhosted.org/packages/32/80/12fda8e896955a0f7ff81176a1ae879b28a3b66248be662dd91132cf933a/pyramid_peewee-0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1afaa633963592a69a8f7aaa0e8bffbb", "sha256": "497d54bb22065389ba5b8727e6195d3ad5319ad98aa566bf7aa38d4e76cc3c4d" }, "downloads": -1, "filename": "pyramid_peewee-0.5.tar.gz", "has_sig": false, "md5_digest": "1afaa633963592a69a8f7aaa0e8bffbb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4962, "upload_time": "2015-08-05T01:03:41", "url": "https://files.pythonhosted.org/packages/7f/66/979a5bf94f5bc0ab606d7ae0628f28a39afd4b71caf4a119f16ab8fb4c3a/pyramid_peewee-0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9f6cfe1888c5d49a95692c1513ad1bc9", "sha256": "9c3adf6e7c4bbffb99485142209314f2e3d19da09b4572f7cd4a816e463304a5" }, "downloads": -1, "filename": "pyramid_peewee-0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "9f6cfe1888c5d49a95692c1513ad1bc9", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 8151, "upload_time": "2015-08-05T01:03:56", "url": "https://files.pythonhosted.org/packages/32/80/12fda8e896955a0f7ff81176a1ae879b28a3b66248be662dd91132cf933a/pyramid_peewee-0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1afaa633963592a69a8f7aaa0e8bffbb", "sha256": "497d54bb22065389ba5b8727e6195d3ad5319ad98aa566bf7aa38d4e76cc3c4d" }, "downloads": -1, "filename": "pyramid_peewee-0.5.tar.gz", "has_sig": false, "md5_digest": "1afaa633963592a69a8f7aaa0e8bffbb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4962, "upload_time": "2015-08-05T01:03:41", "url": "https://files.pythonhosted.org/packages/7f/66/979a5bf94f5bc0ab606d7ae0628f28a39afd4b71caf4a119f16ab8fb4c3a/pyramid_peewee-0.5.tar.gz" } ] }