{ "info": { "author": "V.Anh Tran", "author_email": "tranvietanh1991@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# django-query-execfile\n**Django module for execute sql query in a file**\n\nFull documentation for the project is available at []\n\n---\n\n**Note**:\n\n\n---\n\n# Overview\n\ndjango-query-execfile is a simple library for execute .sql query file.\nEspecially\n\n\n# Requirements\n\n* Python (2.7.x )\n* Django (1.5+ )\n\n# Installation\n\nInstall using `pip`...\n\n```shell\npip install django-query-execfile\n```\n\n\n# Usage & Example\n\nThis is content of a .sql file\n\n```sql\n#sum_customerPayment_amount_rate_exchanged_group_by_day\nSELECT\n DATE(customerPayment.created) AS created,\n SUM(transaction.amount * transaction.exchange_rate) AS amount_exchanged\nFROM shop_module_customerpayment customerPayment\n LEFT JOIN shop_module_transaction transaction ON transaction.id = customerPayment.transaction_id\nWHERE (customerPayment.created BETWEEN %(from_date)s AND %(to_date)s)\nGROUP BY DATE(customerPayment.created);\n```\n\n\nUsage example\n\n```python\nfrom models import Order\nfrom query_execfile import sql_execfile, raw_queryfile\n\nresult = sql_execfile('../datagrip/payment_transaction_stats.sql'),\n params={'from_date': .., 'to_date': ..},\n mapResultToDict=True,\n includeDescription=True\n)\nprint result\n\nrawQuerySet = raw_queryfile(Order, '../datagrip/order_rawquery.sql')\nfor order in rawQuerySet:\n doSomeThingWith(order)\n```\n\n**mapResultToDict=True** will map results to a dict with key = first comment above the query.\nSo you can write multiple query in a single file and execute these query at once.\n\n**includeDescription=True** will add a extra row at first as column header using description from the query.\nIn this case is _AS created_ and _AS amount_exchanged_\n\n\n**Result return of that example:**\n\n```json\n{\"sum_customerPayment_amount_rate_exchanged_group_by_day\": [\n[\n \"created\",\n \"amount_exchanged\"\n],\n[\n \"2016-03-01\",\n 4933000.0\n],\n[\n \"2016-03-02\",\n 7144000.0\n],\n...\n...\n...\n[\n \"2016-03-10\",\n 2110000.0\n]\n],}\n```\n\n\n# Documentation & Support", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/tranvietanh1991/django-query-execfile/archive/master.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tranvietanh1991/django-query-execfile", "keywords": "django,query,sql,execute,file", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-query-execfile", "package_url": "https://pypi.org/project/django-query-execfile/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-query-execfile/", "project_urls": { "Download": "https://github.com/tranvietanh1991/django-query-execfile/archive/master.zip", "Homepage": "https://github.com/tranvietanh1991/django-query-execfile" }, "release_url": "https://pypi.org/project/django-query-execfile/0.6/", "requires_dist": null, "requires_python": null, "summary": "A Django module for execute custom sql query in a .sql file", "version": "0.6" }, "last_serial": 2124867, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "48dc672bf89b092238ed95657c0e8071", "sha256": "59831ef1ec5f3b235bde6c763348c1a4830c40b26f807d7a958323de6a55c858" }, "downloads": -1, "filename": "django-query-execfile-0.1.tar.gz", "has_sig": false, "md5_digest": "48dc672bf89b092238ed95657c0e8071", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2951, "upload_time": "2016-03-30T14:59:04", "url": "https://files.pythonhosted.org/packages/91/bb/b0c3c619f59ff9650be6466be25a11977cc3fea53332c5be2e0d6911d1b3/django-query-execfile-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "e342b4c985bdaa5dcd95a9a307db54e9", "sha256": "65affdbe1c07d5ba84ccca405afe7d8e4a1b09ffc86888bce3c9ebb251329c80" }, "downloads": -1, "filename": "django-query-execfile-0.2.tar.gz", "has_sig": false, "md5_digest": "e342b4c985bdaa5dcd95a9a307db54e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3902, "upload_time": "2016-03-30T17:59:04", "url": "https://files.pythonhosted.org/packages/f5/b2/fed38126f5ad57a22de9d36d36126b8446600eadc7e74956fe57d1050b39/django-query-execfile-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "39af92dde9612555371d22a033b92321", "sha256": "f1403524075f2bc85f31c77de12e458d5d8f18b10906801da8c1ec95b95a789f" }, "downloads": -1, "filename": "django-query-execfile-0.3.tar.gz", "has_sig": false, "md5_digest": "39af92dde9612555371d22a033b92321", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4338, "upload_time": "2016-04-17T08:40:53", "url": "https://files.pythonhosted.org/packages/b5/62/ee528e75f0501636bb75e57be6a3f0b806ef89615d599dac9d8083d5da3c/django-query-execfile-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "6fd359d9488721e0b9db9eaef6f940bf", "sha256": "b10c4a115e5a0c6c4327ce1f483626337170070c5c0229c621cdf65bec3620db" }, "downloads": -1, "filename": "django-query-execfile-0.4.tar.gz", "has_sig": false, "md5_digest": "6fd359d9488721e0b9db9eaef6f940bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4324, "upload_time": "2016-04-17T16:33:13", "url": "https://files.pythonhosted.org/packages/c4/35/6822e0458da2b6fde8d72bd485e630b0eeb269db127df0e32c1b4d04d16d/django-query-execfile-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "2bf20542c67b8388245089ace6ccf1fa", "sha256": "4b73c6dfc5259dd95f74756cf7c67f74ff91572684db024d72e43f0e4046a58d" }, "downloads": -1, "filename": "django-query-execfile-0.5.tar.gz", "has_sig": false, "md5_digest": "2bf20542c67b8388245089ace6ccf1fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4398, "upload_time": "2016-05-18T10:33:57", "url": "https://files.pythonhosted.org/packages/c0/01/f1950ba17ecb63af45ba24ec523492dc2915cbce34909a517835ab0be043/django-query-execfile-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "5f3d972013142b37f1d909d1cb173461", "sha256": "8c06e4b4004e12a8faa7baa80a7e958e23b704b579750d9115284e9441d1ca30" }, "downloads": -1, "filename": "django-query-execfile-0.6.tar.gz", "has_sig": false, "md5_digest": "5f3d972013142b37f1d909d1cb173461", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4500, "upload_time": "2016-05-20T08:49:09", "url": "https://files.pythonhosted.org/packages/c7/d2/0b7d1064a0a68873a3d816ee6f1737f457a65ddbdc3788cf5d4813338d1b/django-query-execfile-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5f3d972013142b37f1d909d1cb173461", "sha256": "8c06e4b4004e12a8faa7baa80a7e958e23b704b579750d9115284e9441d1ca30" }, "downloads": -1, "filename": "django-query-execfile-0.6.tar.gz", "has_sig": false, "md5_digest": "5f3d972013142b37f1d909d1cb173461", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4500, "upload_time": "2016-05-20T08:49:09", "url": "https://files.pythonhosted.org/packages/c7/d2/0b7d1064a0a68873a3d816ee6f1737f457a65ddbdc3788cf5d4813338d1b/django-query-execfile-0.6.tar.gz" } ] }