{ "info": { "author": "Igor Katson", "author_email": "igor.katson@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: POSIX", "Programming Language :: Python", "Topic :: Database", "Topic :: Database :: Front-Ends", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "======\r\n pypq\r\n======\r\n\r\nWhat is pypq\r\n------------\r\n\r\n*pypq* is a `DBAPI 2.0 `_\r\ncompliant Python driver for `PostgreSQL `_,\r\nmade using `ctypes `_ and\r\n`libpq.so `_\r\nlibrary.\r\n\r\nThis means, that it can be used with `PyPy `_, or any other circumstances,\r\nwhere ctypes is available, but *psycopg2*, the most popular PostgreSQL\r\ndriver, is not.\r\n\r\nFeatures\r\n--------\r\n- full DBAPI 2.0 compliance\r\n- fast enough to be compared to psycopg2\r\n- a psycopg2-like extension API\r\n- has a Django backend\r\n- casting of all standard python types implemented, including\r\n datetime, date and timedelta, except converting lists into postgres\r\n arrays and vice versa\r\n\r\nInstallation\r\n------------\r\nJust do::\r\n \r\n easy_install pypq\r\n\r\nOr to download the most recent version from BitBucket::\r\n\r\n hg clone ssh://hg@bitbucket.org/descent/pypq\r\n cd pypyq\r\n python setup.py install\r\n\r\nExample usage\r\n-------------\r\nBasic operations::\r\n\r\n import pypq\r\n connection = pypq.connect('dbname=dbname user=user host=host port=port password=password')\r\n # or\r\n connection = pypq.connect(dbname='dbname', user='user', host='host', \\\r\n port='port', password='password')\r\n # for complete reference look at PQconnectdbParams section at\r\n # http://www.postgresql.org/docs/9.1/static/libpq-connect.htm\r\n cursor = connection.cursor()\r\n cursor.execute('select * from mytable where x = %s', [x])\r\n for row in cursor:\r\n print row\r\n\r\nTo use pypq as a django backend, simply change the 'ENGINE' line to\r\n**\"pypq.django_backend\"** in *settings.py* file. Something like::\r\n \r\n DATABASES = {\r\n 'default': {\r\n 'ENGINE': 'pypq.django_backend',\r\n 'NAME': 'dbname',\r\n 'USER': 'user',\r\n 'PASSWORD': 'password',\r\n 'HOST': 'host',\r\n 'PORT': '',\r\n }\r\n }\r\n\r\n # If using south, change the database adapter\r\n\r\n SOUTH_DATABASE_ADAPTERS = {'default': 'pypq.django_backend.south_adapter'}\r\n\r\nExtending with custom types is done in simimlar way to `psycopg2\r\n`_. Here\r\nare some examples, but you can look at `pypq/datatypes.py\r\n`_ for\r\nadditional ways of usage::\r\n\r\n def adapter(myclass_instance):\r\n \"\"\"A function to adapt MyClass to postgres\r\n\r\n\tIt should return a string and a postgres OID of\r\n\tresulting datatype or 0 if you do not know it\r\n\t (it's ok to do that)\r\n\t\"\"\"\r\n\treturn adapted, oid\r\n\t\r\n # This will allow doing this:\r\n # cursor.execute('select %s', [myclass_instance])\r\n pypq.datatypes.register_adapter(MyClass, adapter)\r\n\r\n # And this will allow doing this, if you have a special type\r\n # in postgres which you want to handle manually, and for \r\n # which you know postgres OIDs:\r\n\r\n # cursor.execute('create table test(a some_special_type)')\r\n # cursor.execute('select * from test')\r\n # and it will fetch your launch to_python(value)\r\n # for every special instance\r\n\r\n def to_python(value):\r\n \"\"\"A function to convert a postgres value into Python object\"\"\"\"\r\n\r\n mytype = pypq.datatypes.new_type((1,2,3), 'MyAwesomeType', to_python))\r\n pypq.datatypes.register_type(mytype)\r\n\r\n # or\r\n \r\n class MyType(pypq.datatypes.PyPQDataType):\r\n\r\n oids = (1,2,3)\r\n\r\n\t@classmethod\r\n\tdef to_python(cls, value):\r\n\t return value\r\n\r\nBugs\r\n----\r\n\r\nThe project currently has some limitations\r\n- no support of postgres arrays yet\r\n- this does not work somewhy, though it works in psycopg2::\r\n\r\n cur.execute('select %s', [None])\r\n DatabaseError: ERROR: could not determine data type of parameter $1\r\n\r\n- Internally, OID's are currently not passed to the database, when\r\n executing PQexecParams. I am not sure, if it is ok, but django works\r\n flawleslly this way, and if we pass the OID's to PQexecParams, it\r\n does not, cause some postgres type casting fails.\r\n- not tested on other python versions than 2.7 and recent pypy\r\n- not tested on windows (it probably won't work)\r\n- not thread-safe, you cannot use same cursors or connections in\r\n different threads", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/descent/pypq", "keywords": "", "license": "UNKNOWN", "maintainer": "", "maintainer_email": "", "name": "pypq", "package_url": "https://pypi.org/project/pypq/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pypq/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/descent/pypq" }, "release_url": "https://pypi.org/project/pypq/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Python PostgreSQL DBAPI 2.0 compliant driver using ctypes and libpq.so, works with PyPy", "version": "0.1.3" }, "last_serial": 797562, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "4793beeec9fe010c65b68eccb8daea44", "sha256": "ed898d5091a2b2a6c5a7a6a4176bd73f436fadd5d52e6f44a7dda163adaffde4" }, "downloads": -1, "filename": "pypq-0.1.1.tar.gz", "has_sig": true, "md5_digest": "4793beeec9fe010c65b68eccb8daea44", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12813, "upload_time": "2011-10-04T10:46:17", "url": "https://files.pythonhosted.org/packages/5a/b6/6995c15a8d32f5e03a8f226988b6c0f1e98185cc69d3dd7eb9a440dc5f7f/pypq-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "df6efab9a92fc743ae1fe070dcddae10", "sha256": "5bb4cbfabc3b3d4428d35c6d6b3e76a0b1c38ed306ec9f97af07920d8b1bc385" }, "downloads": -1, "filename": "pypq-0.1.2.tar.gz", "has_sig": true, "md5_digest": "df6efab9a92fc743ae1fe070dcddae10", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13815, "upload_time": "2011-10-04T13:33:32", "url": "https://files.pythonhosted.org/packages/22/a9/a950663bd9c640f9b1ee4120ba8ae7f8be5483874bf7856c6e0059a0f2a0/pypq-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "59378face5bdb9ae56253c160080a129", "sha256": "a25ebb35f53e643368cc5a854ddbe7607349db82af1159420098fbce7a4acb42" }, "downloads": -1, "filename": "pypq-0.1.3.tar.gz", "has_sig": true, "md5_digest": "59378face5bdb9ae56253c160080a129", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15586, "upload_time": "2011-10-05T12:16:42", "url": "https://files.pythonhosted.org/packages/17/86/11cb7cc8c190c37f743f297ff057265b0ac66bb1793d93240cd73aecf707/pypq-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "59378face5bdb9ae56253c160080a129", "sha256": "a25ebb35f53e643368cc5a854ddbe7607349db82af1159420098fbce7a4acb42" }, "downloads": -1, "filename": "pypq-0.1.3.tar.gz", "has_sig": true, "md5_digest": "59378face5bdb9ae56253c160080a129", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15586, "upload_time": "2011-10-05T12:16:42", "url": "https://files.pythonhosted.org/packages/17/86/11cb7cc8c190c37f743f297ff057265b0ac66bb1793d93240cd73aecf707/pypq-0.1.3.tar.gz" } ] }