{ "info": { "author": "Eric Pruitt", "author_email": "eric.pruitt@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: SQL", "Topic :: Database", "Topic :: Database :: Front-Ends" ], "description": "swadr\r\n=====\r\n\r\nS.W.A.D.R., SQLite3 With Arbitrarily Delimited Records, is designed to\r\nbe a replacement and significant improvement over\r\n`SQLet `__, \"a free, open-source script that\r\nallows you to directly execute SQL on multiple text files, right from\r\nthe Linux command line.\" In addition to augmenting the features of\r\nSQLet, I also elected to use the `BSD 2-Clause\r\nLicense `__ instead of the\r\nGPL (SWADR is derived neither in whole nor part from SQLet).\r\n\r\nSome notable improvements over SQLet are:\r\n\r\n- When importing data with swadr, swadr will automatically detect the\r\n files' delimation type as well as the schema of the data.\r\n- Queries do not need to be piped to SQLite3.\r\n- Swadr provides a built-in SQLite3 REPL designed to emulate the MySQL\r\n CLI.\r\n- Unparseable records will not terminate the execution of the program\r\n by default.\r\n\r\nQuick Example\r\n-------------\r\n\r\nLoad examples/students.csv into the table \"A\" and load grades.csv into\r\nthe table \"B\" then enter interactive mode:\r\n\r\n::\r\n\r\n swadr -A src/samples/students.csv -B src/samples/grades.tsv\r\n sqlite> DESC A;\r\n +-----+-----------+---------+---------+------------+----+\r\n | cid | name | type | notnull | dflt_value | pk |\r\n +-----+-----------+---------+---------+------------+----+\r\n | 0 | Name | TEXT | 0 | NULL | 0 |\r\n | 1 | Class | INTEGER | 0 | NULL | 0 |\r\n | 2 | Home_Room | TEXT | 0 | NULL | 0 |\r\n | 3 | Age | INTEGER | 0 | NULL | 0 |\r\n +-----+-----------+---------+---------+------------+----+\r\n 4 rows in set (0.00 sec)\r\n\r\n sqlite> DESC B;\r\n +-----+------------+---------+---------+------------+----+\r\n | cid | name | type | notnull | dflt_value | pk |\r\n +-----+------------+---------+---------+------------+----+\r\n | 0 | Assignment | INTEGER | 0 | NULL | 0 |\r\n | 1 | Grade | INTEGER | 0 | NULL | 0 |\r\n | 2 | Student | TEXT | 0 | NULL | 0 |\r\n +-----+------------+---------+---------+------------+----+\r\n 3 rows in set (0.00 sec)\r\n\r\n sqlite> SELECT name, AVG(grade) FROM A INNER JOIN B ON name = student\r\n ;> GROUP BY student;\r\n +---------+---------------+\r\n | name | AVG(grade) |\r\n +---------+---------------+\r\n | Jan | 55.0 |\r\n | Lucy | 88.0 |\r\n | Richard | 86.6666666667 |\r\n +---------+---------------+\r\n 3 rows in set (0.00 sec)\r\n\r\nInstallation\r\n------------\r\n\r\nThere are no non-standard modules required to install S.W.A.D.R., but if\r\nthe `wcwidth `__ module is\r\navailable, it will be used to correctly pad tables containing east Asian\r\ncharacters:\r\n\r\n.. figure:: wcwidth-comparison.gif\r\n :alt: Table Screenshot\r\n\r\n Screenshot with Asian characters\r\n\r\nOption 1: setup.py / pip\r\n~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nA setup.py file is provided that will install the \"swadr\" Python module\r\nand a script for launching swadr's CLI. Execute\r\n``python setup.py install`` using sudo or as privileged user to install\r\nthe package globally or run ``python setup.py install --user`` to\r\ninstall the package as the current user.\r\n\r\nAlternatively, swadr can be installed using pip, e.g.:\r\n``pip install swadr`` or ``pip install --user swadr``.\r\n\r\nAfter installation with either pip or setup.py, the \"swadr\" module will\r\nbe importable and, provided your ``PATH`` environment variable is\r\nconfigured correctly, running ``swadr`` at the command line will launch\r\nthe command line interface. The default location for scripts packaged\r\nwith Python modules is generally ``~/.local/bin``, but this can be\r\nchanged using the\r\n`--install-scripts `__\r\noption. The swadr CLI can also be launched by running\r\n``python -m swadr`` once the module has been installed.\r\n\r\nOption 2: Copying\r\n~~~~~~~~~~~~~~~~~\r\n\r\nThe swadr CLI is wholly contained in the file ``./src/swadr.py`` and can\r\nrun independently of the rest of the files in this repository, so swadr\r\ncan be installed by simply copying ``./src/swadr.py`` to a folder listed\r\nin the ``PATH`` environment variable; ``$HOME/bin``, ``/usr/local/bin``,\r\nand ``/usr/bin`` are popular defaults --\r\n``cp ./src/swadr.py ~/bin/swadr && hash -r`` then run ``swadr``.\r\n\r\nCommand Line Options\r\n--------------------\r\n\r\n**NOTE:** Any trailing, non-option arguments will be executed as SQLite3\r\nqueries after the data has been imported.\r\n\r\n--help, -h\r\n~~~~~~~~~~\r\n\r\nShow the CLI documentation and exit.\r\n\r\n-A FILE, ..., -Z FILE\r\n~~~~~~~~~~~~~~~~~~~~~\r\n\r\nAll capital, single-letter options are used to load the specified file\r\ninto the SQLite3 database. If no \"--table\" option has been specified\r\nimmediately preceding the option, the letter name will be used as the\r\ntable name; loading a file with \"-A\" will populate the table \"A\".\r\n\r\n--table=TABLE\r\n~~~~~~~~~~~~~\r\n\r\nName of table used to store the contents of the next specified CSV file.\r\n\r\n--invalid=METHOD\r\n~~~~~~~~~~~~~~~~\r\n\r\nDetermines how rows of invalid data handled. The METHOD can be \"warn\",\r\n\"ignore\", or \"fail\" which will cause the script to emit a warning and\r\nskip the record, silently skip the record or terminate script execution\r\nrespectively. When unspecified, defaults to \"warn.\"\r\n\r\n--loglevel=LEVEL\r\n~~~~~~~~~~~~~~~~\r\n\r\nSet logging verbosity level. In order from the highest verbosity to the\r\nlowest verbosity, can be one of \"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\",\r\n\"CRITICAL\". The default value is \"WARNING.\"\r\n\r\n--pretty\r\n~~~~~~~~\r\n\r\nPretty-print results of queries passed as command line arguments instead\r\nof tab-separating the results.\r\n\r\n--database=FILE\r\n~~~~~~~~~~~~~~~\r\n\r\nPath of the SQLite3 database the queries should be executed on. When\r\nunspecified, the data is stored volatile memory and becomes inaccessible\r\nafter the program stops running.\r\n\r\n-i\r\n~~\r\n\r\nEnter interactive mode after importing data. When the \"--database\" flag\r\nis not specified, this option is implied. In addition to being able to\r\nexecute normal SQLite3 queries, the interpreter also has emulated\r\nsupport for some of MySQL's special statements matching the following\r\ngrammars:\r\n\r\n- {DESC \\| DESCRIBE} **table\\_name**\r\n- SHOW CREATE TABLE **table\\_name**\r\n- SHOW TABLES\r\n\r\n-v\r\n~~\r\n\r\nIncrease logging verbosity. Can be used repeatedly to further increase\r\nverbosity.\r\n\r\n-q\r\n~~\r\n\r\nDecrease logging verbosity. Can be used repeatedly to further decrease\r\nverbosity.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ericpruitt/swadr", "keywords": "sqlite,sqlite3,sql,csv,tsv", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "swadr", "package_url": "https://pypi.org/project/swadr/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/swadr/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/ericpruitt/swadr" }, "release_url": "https://pypi.org/project/swadr/1.2.1/", "requires_dist": null, "requires_python": null, "summary": "Import data from CSV, TSV, etc. files into SQLite3 database.", "version": "1.2.1" }, "last_serial": 1537244, "releases": { "1.2.1": [] }, "urls": [] }