{ "info": { "author": "Michel Casabianca", "author_email": "casa@sweetohm.net", "bugtrack_url": null, "classifiers": [], "description": "mysql\\_commando\n===============\n\nInstalling a MySQL driver on a machine is sometime a pain, or even\nimpossible. Furthermore you may want to distribute self contained\nscripts that access MySQL without having to ask for additional software\ninstallation.\n\n*mysql\\_commando* is a pure Python MySQL driver that calls MySQL running\nthe client on the command line. It was designed so that you may use it\nby dropping its module in your source tree or even copy its class in\nyour own source code.\n\nInstallation\n------------\n\nTo install *mysql\\_commando*, you may use one of the following methods:\n\n- Extract its classes ``MysqlCommando`` and ``MysqlException`` from\n tarball (in file *mysql\\_commando/mysql\\_commando.py*) and put it in\n your own source code.\n- Drop its module (file *mysql\\_commando/mysql\\_commando.py* in the\n tarball) in your source directory.\n- Install it using PIP, typing ``pip install mysql_commando``.\n- Install from tarball typing ``python setup.py install``.\n\nThe Apache license grants you a right to use this driver in any of your\nproject (even commercial) provided that you mention that you are using\n*mysql\\_commando* in your copyright notice.\n\nUsage\n-----\n\nYou can use this driver in your code just like so:\n\n.. code:: python\n\n from mysql_commando import MysqlCommando\n\n mysql = MysqlCommando(hostname='localhost', database='test',\n username='test', password='test')\n result = mysql.run_query(\"SHOW DATABASES\")\n print resul\n\nWhen query returns nothing (after an ``INSERT`` for instance), method\n``run_query()`` will return ``None``. If query returns a result set,\nthis will be a tuple of dictionaries. For instance, previous sample code\ncould print:\n\n.. code:: python\n\n ({'Database': 'information_schema'}, {'Database': 'mysql'})\n\nInstead of running a query you may run a script as follows:\n\n.. code:: python\n\n result = mysql.run_script('my_script.sql')\n\nParameters\n----------\n\nYou can have values such as ``%(foo)s`` in you query that will be\nreplaced with corresponding value of the parameters dictionary. For\ninstance:\n\n.. code:: python\n\n from mysql_commando import MysqlCommando\n\n mysql = MysqlCommando(hostname='localhost', database='test',\n username='test', password='test')\n parameters = {'name': 'reglisse'}\n result = mysql.run_query(query=\"SELECT * FROM animals WHERE name=%(name)s\",\n parameters=parameters)\n print result\n\nYou may not provide parameters running a script. To do so, call\n``run_query()`` with parameters passing query\n``open('my_script.sql').read()``.\n\nResult set types\n----------------\n\n*mysql\\_commando* performs auto casting before returning result sets. As\nit calls MySQL on command line, every value in the result set is a\nstring. For convenience, it casts integers, floats, dates and NULL into\nnative Python types.\n\nThere are situations where this might not be accurate. For instance, if\na column is of SQL type ``VARCHAR(10)`` and contain phone numbers, all\nits values will be casted to Python integers. It should not because\nphone numbers can start with *0* and it should not be turned to integer.\n\nTo avoid this, you may pass ``cast=False`` when calling ``run_query()``\nor ``run_script()``, like so:\n\n.. code:: python\n\n from mysql_commando import MysqlCommando\n\n mysql = MysqlCommando(hostname='localhost', database='test',\n username='test', password='test')\n result = mysql.run_query(\"SELECT phone FROM users WHERE name='bob')\", cast=False)\n print result\n\nYou may also disable casting when instantiating the driver, passing\n``cast=False`` to the constructor. This casting configuration will apply\non all calls to ``run_query()`` or ``run_script()`` except if you pass a\ndifferent value while calling these methods.\n\nLast insert ID\n--------------\n\nTo get the ID of the last ``INSERT`` of a given query, you can pass\n``last_insert_id=True`` while calling ``run_query()``, as follows:\n\n.. code:: python\n\n query = \"INSERT INTO animals (name, age) VALUES ('Reglisse', 14)\"\n id = mysql.run_query(query, last_insert_id=True)\n print id\n\nThis will return the last ``INSERT`` ID as an integer.\n\nIf you need to get ID of the last ``INSERT`` running a script, just add\na call to MySQL function ``last_insert_id()`` like so:\n\n.. code:: python\n\n INSERT INTO animals (name, age) VALUES ('Reglisse', 14);\n SELECT last_insert_id() AS id;\n\nWhile you run this script, this will return the ID of your last\n``INSERT``:\n\n.. code:: python\n\n ({'id': 1},)\n\nNote\n----\n\nThis module is not intended to replace MySQLdb that you SHOULD use if\nyou can install it on the target machine.\n\nEnjoy!", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/mysql_commando/", "keywords": null, "license": "Apache Software License", "maintainer": null, "maintainer_email": null, "name": "mysql_commando", "package_url": "https://pypi.org/project/mysql_commando/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mysql_commando/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/mysql_commando/" }, "release_url": "https://pypi.org/project/mysql_commando/0.5.0/", "requires_dist": null, "requires_python": null, "summary": "mysql_commando is an Oracle driver calling mysql", "version": "0.5.0" }, "last_serial": 2120072, "releases": { "0.3.2": [ { "comment_text": "", "digests": { "md5": "75a2929e03fab1f15837e0ad15b33cad", "sha256": "7efb2dbc24c564a4da10b9e07735eb2e1a88e6b6a600158147f38c1cd81154c7" }, "downloads": -1, "filename": "mysql_commando-0.3.2.tar.gz", "has_sig": false, "md5_digest": "75a2929e03fab1f15837e0ad15b33cad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3782, "upload_time": "2014-03-31T22:58:20", "url": "https://files.pythonhosted.org/packages/a4/2b/a23886dd14e01acc02af7fee6ba3f285f41ac53925f62f2ca2e855d1fb5b/mysql_commando-0.3.2.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "108ecf2cd78d1931179854f090df71bc", "sha256": "d59cdfea6be688104547c6115735a71741eeb79a0117fa7a70759591a15b3d51" }, "downloads": -1, "filename": "mysql_commando-0.4.0.tar.gz", "has_sig": false, "md5_digest": "108ecf2cd78d1931179854f090df71bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3962, "upload_time": "2014-03-31T23:40:20", "url": "https://files.pythonhosted.org/packages/27/2d/d56d01dfebb002a3a1cd26d836ee5528a5ba0bc8f12a9033729ca3fa5bae/mysql_commando-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "881e9a25d5ebf75cc7fae7cad82daa79", "sha256": "8f2f14b3fea92f13f3046dc5ca5332b07d32b18f83d31a6c6d4951c112f47882" }, "downloads": -1, "filename": "mysql_commando-0.4.1.tar.gz", "has_sig": false, "md5_digest": "881e9a25d5ebf75cc7fae7cad82daa79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3973, "upload_time": "2014-04-01T00:06:57", "url": "https://files.pythonhosted.org/packages/de/9e/5157adb7e120b3c66f479020db0f30984b3998b546ea58797508a6f38066/mysql_commando-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "dbce0473df29ee3677a87068ae817064", "sha256": "839c185602614816f2bbf0cc632e2cf8655f195570d3aa83b4d2eace36f64b79" }, "downloads": -1, "filename": "mysql_commando-0.4.2.tar.gz", "has_sig": false, "md5_digest": "dbce0473df29ee3677a87068ae817064", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8368, "upload_time": "2014-04-03T12:42:03", "url": "https://files.pythonhosted.org/packages/5d/1c/ef3d121eedc07a50ef446870333ed582fa50b3112e2c78a8c18eda1288af/mysql_commando-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "a4f7f569cba715f7e9b79d7feb311abb", "sha256": "deadbdf427f9121ddf18f101ad1b61405f930f1e56f1bb8777ec065ae7b79cc7" }, "downloads": -1, "filename": "mysql_commando-0.4.3.tar.gz", "has_sig": false, "md5_digest": "a4f7f569cba715f7e9b79d7feb311abb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8390, "upload_time": "2014-04-03T16:44:53", "url": "https://files.pythonhosted.org/packages/6e/f9/5b2473c8228744af9254765e620c088215ae74d53c728781eafd633b99c0/mysql_commando-0.4.3.tar.gz" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "63bafec078211e5500bc074b0ce53856", "sha256": "382f2b117c76d691a7ab82d5885f67ee1384329c44446abfcb38cf6406129b7d" }, "downloads": -1, "filename": "mysql_commando-0.4.5.tar.gz", "has_sig": false, "md5_digest": "63bafec078211e5500bc074b0ce53856", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8433, "upload_time": "2014-11-25T16:04:17", "url": "https://files.pythonhosted.org/packages/57/3e/a41642fb4c7b76ea52bd8db61e2c13bc47d768bc8b3c1bd1d5dda47673d9/mysql_commando-0.4.5.tar.gz" } ], "0.4.6": [ { "comment_text": "", "digests": { "md5": "1f98a3873375f34fcf16789845819a9c", "sha256": "dc9b18a7ddd5a6e3058dbb8c456631f2556d0a360126275b8fb8732d5102a7e2" }, "downloads": -1, "filename": "mysql_commando-0.4.6.tar.gz", "has_sig": false, "md5_digest": "1f98a3873375f34fcf16789845819a9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8499, "upload_time": "2014-12-09T10:52:26", "url": "https://files.pythonhosted.org/packages/e6/27/093f78f6ab975329f05204ffb564c9359948425023615526e225d4ba4207/mysql_commando-0.4.6.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "f0c7da847522379b9a7e885b87c757ca", "sha256": "e12053d5cb2c2fb21b49f99c5afa81e244ee8c2d256b99d1818e9f4fb8ed4196" }, "downloads": -1, "filename": "mysql_commando-0.5.0.tar.gz", "has_sig": false, "md5_digest": "f0c7da847522379b9a7e885b87c757ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8206, "upload_time": "2016-05-17T15:28:54", "url": "https://files.pythonhosted.org/packages/76/a3/5efb39057eb053a5b63b0aa5e6fa84d8fe64c6ed8c38a4d2cdfca591da68/mysql_commando-0.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f0c7da847522379b9a7e885b87c757ca", "sha256": "e12053d5cb2c2fb21b49f99c5afa81e244ee8c2d256b99d1818e9f4fb8ed4196" }, "downloads": -1, "filename": "mysql_commando-0.5.0.tar.gz", "has_sig": false, "md5_digest": "f0c7da847522379b9a7e885b87c757ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8206, "upload_time": "2016-05-17T15:28:54", "url": "https://files.pythonhosted.org/packages/76/a3/5efb39057eb053a5b63b0aa5e6fa84d8fe64c6ed8c38a4d2cdfca591da68/mysql_commando-0.5.0.tar.gz" } ] }