{ "info": { "author": "Wolfang Torres", "author_email": "wolfang.torres@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# SQL_XML_TABLE #\n\nAn object that allows you to easily create and work with tables, while also importing/exporting them from/to SQL databases or XML files, it can serve as a way to send data back and ford between XML files and SQL databases.\n\n\n\n```\n#!python\n\n>From sql_xml_table import Table\n```\n\n\nIt defines an object called Table, it can be created with a name for identification an a pre-created connection object of a pep-246 compatible database interface.\n\n\n```\n#!python\n\ntable = Table('Animals') \n```\n\nThen you need to add columns with the agregar_columna (add_column) method, with can take various key word arguments:\n\n - campo (field): the name of the field\n\n - tipo (type): the type of data stored, can be a things like 'varchar' and 'double' or name of python objects if you aren't interested in exporting to a data base latter.\n\n - defecto (default): set a default value for the column if there is none when you add a row\n\n - there are other 3 but are only there for database tings and not actually functional\n\nlike:\n\n\n```\n#!python\nTable.agregar_columna(campo='Name', tipo='str')\nTable.agregar_columna(campo='Year', tipo='date')\n\ndeclaring it date, time, datetime or timestamp is important for being able to store it as a time object and not only as a number, But you can always put it as a int if you don't care for dates\n\nTable.agregar_columna(campo='Priority', tipo='int')\n```\n\nThen you add the rows with the += operator (or + if you want to create a copy with an extra row)\n\n\n```\n#!python\n\nTable += ('Cat', date(1998,1,1), 1)\nTable += {'Year':date(1998,1,1), 'Priority':2, Name:'Fish'}\n#\u00e2\u20ac\u00a6\n#The condition for adding is that is a container accessible with either the column name or the position of the column in the table\n```\n\nThen you can generate XML and write it to a file with exportar_XML (export_XML) and escribir_XML (write_XML):\n\n\n```\n#!python\n\nfile = os.path.abspath(os.path.join(os.path.dirname(__file__), 'Animals.xml'))\nTable.exportar_xml()\nTable.escribir_xml(file)\n```\n\n\nAnd then import it back with importar_XML (import_XML) with the file name and indication that you are using a file and not an string literal:\n\n\n```\n#!python\n\nTable.importar_xml(file, tipo='archivo')\n#archivo means file\n```\n\n\n# Advanced #\n\nThis are ways you can use a Table object in a SQL manner.\n\n## UPDATE SET Name = CONCAT(Name,' ',Priority), Priority = NULL WHERE id = 2 ##\n\n```\n#!python\n\nfor row in Table:\n if row['id'] == 2:\n row['Name'] += ' ' + row['Priority']\n row['Priority'] = None\nprint(Table)\n```\n\n\n## DELETE FROM
WHERE MOD(id,2) = 0 LIMIT 1 ##\n\n```\n#!python\n\nn = 0\nnmax = 1\nfor row in Table:\n if row['id'] % 2 == 0:\n del Table[row]\n n += 1\n if n >= nmax: break\nprint(Table)\n```\n\n\nthis examples assume a column named 'id' but can be replaced width row.pos for your example.\n\n```\n#!python\n\n\nif row.pos == 2:\n```\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/WolfangT/sql_xml_table", "keywords": "SQL XML Table MySQL SQLite3", "license": "GNU", "maintainer": "", "maintainer_email": "", "name": "sql-xml-table", "package_url": "https://pypi.org/project/sql-xml-table/", "platform": "", "project_url": "https://pypi.org/project/sql-xml-table/", "project_urls": { "Homepage": "https://github.com/WolfangT/sql_xml_table" }, "release_url": "https://pypi.org/project/sql-xml-table/0.1.1/", "requires_dist": [ "pymysql", "python-sql" ], "requires_python": ">=2.6, <4", "summary": "Small Python2/3 module to easily work with tables and import/export them to/from SQL databases and XML files", "version": "0.1.1" }, "last_serial": 3010865, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "0f2a303504d1f5527aa5796db427a2cb", "sha256": "71073955d8e64729d4011d5392232ec3a5979bbc01cd0290952fb00900312982" }, "downloads": -1, "filename": "sql_xml_table-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0f2a303504d1f5527aa5796db427a2cb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.6, <4", "size": 12398, "upload_time": "2017-07-10T00:41:32", "url": "https://files.pythonhosted.org/packages/f5/94/e85d7f6c6b2379089bdeacc4041f247f48e91ac8883482dc240e0598002f/sql_xml_table-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a59263ee15d1a566b8d29bbf52f6b3f8", "sha256": "a1be900c97264e0cf215e062d5737b00aea819a2c8492a62d7cc4eb5585afcef" }, "downloads": -1, "filename": "sql_xml_table-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a59263ee15d1a566b8d29bbf52f6b3f8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.6, <4", "size": 11156, "upload_time": "2017-07-10T00:41:37", "url": "https://files.pythonhosted.org/packages/89/54/e7540ed8657d02291b0fcccee3d334945c03aca6c5c62019b35caa1669a2/sql_xml_table-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0f2a303504d1f5527aa5796db427a2cb", "sha256": "71073955d8e64729d4011d5392232ec3a5979bbc01cd0290952fb00900312982" }, "downloads": -1, "filename": "sql_xml_table-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0f2a303504d1f5527aa5796db427a2cb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.6, <4", "size": 12398, "upload_time": "2017-07-10T00:41:32", "url": "https://files.pythonhosted.org/packages/f5/94/e85d7f6c6b2379089bdeacc4041f247f48e91ac8883482dc240e0598002f/sql_xml_table-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a59263ee15d1a566b8d29bbf52f6b3f8", "sha256": "a1be900c97264e0cf215e062d5737b00aea819a2c8492a62d7cc4eb5585afcef" }, "downloads": -1, "filename": "sql_xml_table-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a59263ee15d1a566b8d29bbf52f6b3f8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.6, <4", "size": 11156, "upload_time": "2017-07-10T00:41:37", "url": "https://files.pythonhosted.org/packages/89/54/e7540ed8657d02291b0fcccee3d334945c03aca6c5c62019b35caa1669a2/sql_xml_table-0.1.1.tar.gz" } ] }