{ "info": { "author": "ScraperWiki Ltd.", "author_email": "pypi@scraperwiki.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: SQL", "Topic :: Database :: Front-Ends" ], "description": "DumpTruck\n==============\nDumpTruck is a document-like interface to a SQLite database.\n\nQuick start\n----------\nInstall, save data and retrieve it using default settings.\n\n### Install\n\n pip2 install dumptruck || pip install dumptruck\n\n### Initialize\n\nOpen the database connection by initializing the a DumpTruck object\n\n from dumptruck import DumpTruck\n\n dt = DumpTruck()\n\n### Save\nThe simplest `insert` call looks like this.\n\n dt.insert({\"firstname\":\"Thomas\",\"lastname\":\"Levine\"})\n\nThis saves a new row with \"Thomas\" in the \"firstname\" column and\n\"Levine\" in the \"lastname\" column. It uses the table \"dumptruck\"\ninside the database \"dumptruck.db\". It creates or alters the table\nif it needs to.\n\nIf you insert one row, `DumpTruck.insert` returns the rowid of the row.\n\n dt.insert({\"foo\", \"bar\"}, \"new-table\") == 1\n\nIf you insert many rows, `DumpTruck.insert` returns a list of the rowids of the\nnew rows.\n\n dt.insert([{\"foo\", \"one\"}, {\"foo\", \"two\"}], \"new-table\") == [2, 3]\n\nIf there are UNIQUE constraints on the table (perhaps from `create_index`) then\n`insert` will fail if these constraints are violated. You can use `upsert` (with\nthe same syntax) to replace the existing row instead.\n\n### Retrieve\nOnce the database contains data, you can retrieve them.\n\n data = dt.dump()\n\nThe data come out as a list of ordered dictionaries,\nwith one dictionary per row.\n\nSlow start\n-------\n### Initialize\n\nYou can specify a few of keyword arguments when you initialize the DumpTruck object.\nFor example, if you want the database file to be `bucket-wheel-excavators.db`,\nyou can use this.\n\n dt = DumpTruck(dbname=\"bucket-wheel-excavators.db\")\n\nIt actually takes up to four keyword arguments.\n\n DumpTruck(dbname='dumptruck.db', auto_commit = True, vars_table = \"_dumptruckvars\", adapt_and_convert = True)\n\n* `dbname` is the database file to save to; the default is dumptruck.db.\n* `vars_table` is the name of the table to use for `DumpTruck.get_var`\n and `DumpTruck.save_var`; default is `_dumptruckvars`. Set it to `None`\n to disable the get_var and save_var methods.\n* `auto_commit` is whether changes to the database should be automatically committed;\n if it is set to `False`, changes must be committed with the `commit` method\n or with the `commit` keywoard argument.\n* `adapt_and_convert` is whether types should be converted automatically; with\n this on dates get inserted as dates, lists as lists, &c.\n\n### Saving\nAs discussed earlier, the simplest `insert` call looks like this.\n\n dt.insert({\"firstname\": \"Thomas\", \"lastname\": \"Levine\"})\n\n#### Different tables\nBy default, that saves to the table `dumptruck`. You can specify a different table;\nthis saves to the table `diesel-engineers`.\n\n dt.insert({\"firstname\": \"Thomas\", \"lastname\": \"Levine\"}, \"diesel-engineers\")\n\n#### Multiple rows\nYou can also pass a list of dictionaries.\n\n data=[\n {\"firstname\": \"Thomas\", \"lastname\": \"Levine\"},\n {\"firstname\": \"Julian\", \"lastname\": \"Assange\"}\n ]\n dt.insert(data)\n\n#### Complex objects\nYou can even pass nested structures; dictionaries,\nsets and lists will automatically be dumped to JSON.\n\n data=[\n {\"title\":\"The Elements of Typographic Style\",\"authors\":[\"Robert Bringhurst\"]},\n {\"title\":\"How to Read a Book\",\"authors\":[\"Mortimer Adler\",\"Charles Van Doren\"]}\n ]\n dt.insert(data)\n\nYour data will be stored as JSON. When you query it, it will\ncome back as the original Python objects.\n\nAnd if you have some crazy object that can't be JSONified,\nyou can use the dead-simple pickle interface.\n\n # This fails\n data = {\"weirdthing\": {range(100): None}\n dt.insert(data)\n\n # This works\n from dumptruck import Pickle\n data = Pickle({\"weirdthing\": {range(100): None})\n dt.insert(data)\n\nIt automatically pickles and unpickles your complex object for you.\n\n#### Names\nColumn names and table names automatically get quoted if you pass them without quotes,\nso you can use bizarre table and column names, like `no^[hs!'e]?'sf_\"&'`\n\n#### Null values\n`None` dictionary values are always equivalent to non-existence of the key.\nThat is, these insert commands are equivalent.\n\n dt = DumpTruck()\n dt.insert({ u'foo': 8, u'bar': None})\n dt.insert({ u'foo': 8})\n\nPassing an empty dictionary creates a new row with all NULL values.\n\n # These all create a row with all NULL values.\n dt.insert({})\n dt.insert([{}])\n dt.insert({u'potato': None})\n\nMore precisely, they set the values to the default values via this SQL.\n\n INSERT INTO foo DEFAULT VALUES\n\nPassing an empty list to `insert` inserts zero rows (rather than one);\nthis command does nothing.\n\n dt.insert([])\n\nYou can pass zero rows or empty rows to `DumpTruck.insert`, but you'll get an\nerror if you try passing them to `DumpTruck.create_table`.\n\n### Retrieving\n\nYou can use normal SQL to retrieve data from the database.\n\n data = dt.execute('SELECT * FROM `diesel-engineers`')\n\nThe data come back as a list of dictionaries, one dictionary\nper row. They are coerced to different python types depending\non their database types.\n\n### Individual values\nIt's often useful to be able to quickly and easily save one metadata value.\nFor example, you can record which page the last run of a script managed to get up to.\n\n dt.save_var('last_page', 27)\n 27 == dt.get_var('last_page')\n\nIt's stored in a table that you can specify when initializing DumpTruck.\nIf you don't specify one, it's stored in `_dumptruckvars`.\n\nIf you want to save anything other than an int, float or string type,\nuse json or pickle.\n\n### Helpers\nDumpTruck provides specialized wrapper around some common commands.\n\n`DumpTruck.tables` returns a set of all of the tables in the database.\n\n dt.tables()\n\n`DumpTruck.drop` drops a table.\n\n dt.drop(\"diesel-engineers\")\n\n`DumpTruck.dump` returns the entire particular table as a list of dictionaries.\n\n dt.dump(\"coal\")\n\nIt's equivalent to running this:\n\n dt.execute('SELECT * from `coal`;')\n\n### Creating empty tables\nWhen working with relational databases, one typically defines a schema\nbefore populating the database. You can use the `DumpTruck.insert` method\nlike this by calling it with `create_only = True`.\n\nFor example, if the table `tools` does not exist, the following call will create the table\n`tools` with the columns `toolName` and `weight`, with the types `TEXT` and `INTEGER`,\nrespectively, but will not insert the dictionary values (\"jackhammer\" and 58) into the table.\n\n dt.create_table({\"toolName\":\"jackhammer\", \"weight\": 58}, \"tools\")\n\nIf you are concerned about the order of the tables, pass an OrderedDict.\n\n dt.create_table(OrderedDict([(\"toolName\", \"jackhammer\"), (\"weight\", 58)]), \"tools\")\n\nThe columns will be created in the specified order.\n\n### Indices\n\n#### Creating\nDumpTruck contains a special method for creating indices. To create an index,\nfirst create an empty table. (See \"Creating empty tables\" above.)\nThen, use the `DumpTruck.create_index` method.\n\n dt.create_index(['toolName'], 'tools')\n\nThis will create a non-unique index on the column `tool`. To create a unique\nindex, use the keyword argument `unique = True`.\n\n dt.create_index(['toolName'], 'tools', unique = True)\n\nYou can also specify multi-column indices.\n\n dt.create_index(['toolName', 'weight'], 'tools')\n\nDumpTruck names these indices according to the names of the relevant table and columns.\nThe index created in the previous example might be named `dt__tools_toolName_weight`.\n\n#### Other index manipulation\nDumpTruck does not implement special methods for viewing or removing indices, but here\nare the relevant SQLite SQL commands.\n\nThe following command lists indices on the `tools` table.\n\n dt.execute('PRAGMA index_list(tools)')\n\nThe following command gives more information about the index named `dt__tools_toolName_weight`.\n\n dt.execute('PRAGMA index_info(dt__tools_toolName_weight)')\n\nAnd this one deletes the index.\n\n dt.execute('DROP INDEX dt__tools_toolName_weight')\n\nFor more information on indices and, particularly, the `PRAGMA` commands, check\nthe [SQLite documentation]().\n\n### Delaying commits\nBy default, the `insert`, `get_var`, `drop` and `execute` methods automatically commit changes.\nYou can stop one of them from committing by passing `commit=False` to the method.\nCommit manually with the `commit` method. For example:\n\n dt = DumpTruck()\n dt.insert({\"name\":\"Bagger 293\",\"manufacturer\":\"TAKRAF\",\"height\":95}, commit=False)\n dt.save_var('page_number', 42, commit=False)\n dt.commit()\n", "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/scraperwiki/dumptruck.git", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "dumptruck", "package_url": "https://pypi.org/project/dumptruck/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dumptruck/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/scraperwiki/dumptruck.git" }, "release_url": "https://pypi.org/project/dumptruck/0.1.6/", "requires_dist": null, "requires_python": null, "summary": "Relaxing interface to SQLite", "version": "0.1.6" }, "last_serial": 4653395, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "2c0db8440854abb926801f7a92ba16a0", "sha256": "9fd43a9a40a4d6e173d60236937faa840dfdd309fd387f1770abe57acb0753d8" }, "downloads": -1, "filename": "dumptruck-0.0.1.tar.gz", "has_sig": false, "md5_digest": "2c0db8440854abb926801f7a92ba16a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23494, "upload_time": "2012-04-19T01:33:03", "url": "https://files.pythonhosted.org/packages/19/6d/d06babcefd5686c4474085ef635d1aec3f006c57cc9b35ab6b1511aa35bd/dumptruck-0.0.1.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "dcc65e58bdb1f77a7307e46f36a9c178", "sha256": "d8402ce9afe1ce65fb8d64eceeff3f1d8157ee902259460ffc11ef5dce28308a" }, "downloads": -1, "filename": "dumptruck-0.0.3.tar.gz", "has_sig": false, "md5_digest": "dcc65e58bdb1f77a7307e46f36a9c178", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27280, "upload_time": "2012-08-02T14:27:44", "url": "https://files.pythonhosted.org/packages/92/3a/9a922df022fe5b58b7953e73fc10749ee0df529b5fba003346a402a168a3/dumptruck-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "c4334feb0c5cd1d5b281ed7725c7dba9", "sha256": "1134ed777ac846565bd0d2f6c003309f7a51a4ce374de62a172708ca6a5bc280" }, "downloads": -1, "filename": "dumptruck-0.0.4.tar.gz", "has_sig": false, "md5_digest": "c4334feb0c5cd1d5b281ed7725c7dba9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27272, "upload_time": "2012-08-07T20:31:01", "url": "https://files.pythonhosted.org/packages/8c/59/bda2a3667700c964919fdae5505aa59e04d0cf4d2cae715e429299a1b45f/dumptruck-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "de6934e5f0d1150b4d04292279dfcd71", "sha256": "3f7811bf55bdb98d444c33ca7d0b1bc07038d02ae42ca08f0eccb067aab52afb" }, "downloads": -1, "filename": "dumptruck-0.0.5.tar.gz", "has_sig": false, "md5_digest": "de6934e5f0d1150b4d04292279dfcd71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27262, "upload_time": "2012-09-25T16:02:20", "url": "https://files.pythonhosted.org/packages/24/41/8a05e301092d37e839ea8c41f2b8afcb8fca0d1c9177bbb83116eb64e720/dumptruck-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "6940a6118e1a02ce546a2005c269cf11", "sha256": "2e2f98ee1d3cbefd0f84b642a57e4a163050af08cf5113857fa52bd4e2b282d3" }, "downloads": -1, "filename": "dumptruck-0.0.6.tar.gz", "has_sig": false, "md5_digest": "6940a6118e1a02ce546a2005c269cf11", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27848, "upload_time": "2012-09-26T15:22:53", "url": "https://files.pythonhosted.org/packages/5d/8e/9792199d1f706b58c13818b55a476d46b7ffaaab605c28d4754d4fbf5ac4/dumptruck-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "de026575d90e81265943bfcd11aa490b", "sha256": "5078b400fe6838fdef0a5c2d92c04c96d107f441a3b647d5e20241ca9d490bd8" }, "downloads": -1, "filename": "dumptruck-0.0.7.tar.gz", "has_sig": false, "md5_digest": "de026575d90e81265943bfcd11aa490b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16492, "upload_time": "2012-10-09T11:11:14", "url": "https://files.pythonhosted.org/packages/c9/c5/dad849756193f8077fd104182190eb4f37a83d8560cd95f5b7b0a4c859fe/dumptruck-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "9f95f0055b09ddf69ebc6c303f24cb54", "sha256": "640a7e7a5e330ec42a008e2d3fc0a981bbd96290167509ed8f669d7338deaf2f" }, "downloads": -1, "filename": "dumptruck-0.0.8.tar.gz", "has_sig": false, "md5_digest": "9f95f0055b09ddf69ebc6c303f24cb54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16448, "upload_time": "2012-11-12T14:41:55", "url": "https://files.pythonhosted.org/packages/9b/d3/19a01135cf0c9ea4ee143071a3cffbaaf0b4f021870080d6eb4c1008da2a/dumptruck-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "f36b5a2b6bb4f7f65cc29c0d85e14412", "sha256": "068f7aef4a3a8965f54b099644b26ceb70e4a636b648cf187ebe2d4847e41e9f" }, "downloads": -1, "filename": "dumptruck-0.0.9.tar.gz", "has_sig": false, "md5_digest": "f36b5a2b6bb4f7f65cc29c0d85e14412", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16404, "upload_time": "2012-11-12T14:50:58", "url": "https://files.pythonhosted.org/packages/6d/9a/d53eaeb21c62a2e8073578bad9aae512f68616b0473cd3ea4b22d4e3a8f2/dumptruck-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "8377e1b0e0bdef5384db5bd25f13219d", "sha256": "7fe95977615dfd4caa1cb104563de1dafdd2d58f52f86d8f9ce081edb431601a" }, "downloads": -1, "filename": "dumptruck-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8377e1b0e0bdef5384db5bd25f13219d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16462, "upload_time": "2012-11-16T17:29:39", "url": "https://files.pythonhosted.org/packages/09/fe/0d3641a53fe2e148a40a7cad9b226d697d139bba02b5d76025f672a60a21/dumptruck-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "707be94f18f8bee5cb6e4d3172722fad", "sha256": "b6e85e4f9b3bb4171b03540839fed6dd210b0cb0ef4b47de3ff667c1603af428" }, "downloads": -1, "filename": "dumptruck-0.1.1.tar.gz", "has_sig": false, "md5_digest": "707be94f18f8bee5cb6e4d3172722fad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16556, "upload_time": "2013-01-03T16:43:09", "url": "https://files.pythonhosted.org/packages/e2/7f/f7f54ccbeed153873d84be0d57a6c3e069e384e999338d4c39db2a9a14a8/dumptruck-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "ac3db6f438bf82cc4d1e41f0c044e174", "sha256": "a455fe934aeab20071436953bb984279e490518a6236c49fc0168f1a60486b2b" }, "downloads": -1, "filename": "dumptruck-0.1.2.tar.gz", "has_sig": false, "md5_digest": "ac3db6f438bf82cc4d1e41f0c044e174", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15029, "upload_time": "2013-02-18T17:51:18", "url": "https://files.pythonhosted.org/packages/74/b1/9324ba948896c8036ecec19b06bfc54d71fc0bb58cc3aa61353de5eaa097/dumptruck-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "94fbb68e489fa96bf7acee209c58cbd2", "sha256": "e0b65318488e9778683bc2bfbe1dff1f3f7c675864308a8300d28bc8c9645292" }, "downloads": -1, "filename": "dumptruck-0.1.3.tar.gz", "has_sig": false, "md5_digest": "94fbb68e489fa96bf7acee209c58cbd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15288, "upload_time": "2013-02-19T14:10:36", "url": "https://files.pythonhosted.org/packages/dd/4d/f9f547b357cebede502cd749ba92df3b2a1ab580d1d98998b9afa360defd/dumptruck-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "21bbf43602a700a1d4a9402e5debe6f1", "sha256": "e120d433d45346102f606104fc155a7901e25531da3a6975ca7808d0ffe126e4" }, "downloads": -1, "filename": "dumptruck-0.1.4.tar.gz", "has_sig": false, "md5_digest": "21bbf43602a700a1d4a9402e5debe6f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15380, "upload_time": "2013-02-19T15:27:02", "url": "https://files.pythonhosted.org/packages/b6/ff/f6cead2cf06b184900c62760982d2421e0fcf3b1d6fe2de7c9df76fda4b3/dumptruck-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "63af09515e60ea33dc4cdc760c2c3764", "sha256": "7e375dac416024ecbbec1c3cb4d0eb138fb435870777261c3cc1b1642b538cb8" }, "downloads": -1, "filename": "dumptruck-0.1.5.tar.gz", "has_sig": false, "md5_digest": "63af09515e60ea33dc4cdc760c2c3764", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15385, "upload_time": "2013-08-01T11:23:21", "url": "https://files.pythonhosted.org/packages/59/0b/09ad3ede676dd2cae7def0dcbb417ee92481d692010a210c8854f859c53d/dumptruck-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "ac4aa3ebb3008823587b82a4891b8e9e", "sha256": "26cb612f2e2755c10b43b3b7b8e2bb2dd164df47cf802abe377bce3812f8c5e0" }, "downloads": -1, "filename": "dumptruck-0.1.6.tar.gz", "has_sig": false, "md5_digest": "ac4aa3ebb3008823587b82a4891b8e9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15384, "upload_time": "2014-05-19T09:07:46", "url": "https://files.pythonhosted.org/packages/15/27/3330a343de80d6849545b6c7723f8c9a08b4b104de964ac366e7e6b318df/dumptruck-0.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ac4aa3ebb3008823587b82a4891b8e9e", "sha256": "26cb612f2e2755c10b43b3b7b8e2bb2dd164df47cf802abe377bce3812f8c5e0" }, "downloads": -1, "filename": "dumptruck-0.1.6.tar.gz", "has_sig": false, "md5_digest": "ac4aa3ebb3008823587b82a4891b8e9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15384, "upload_time": "2014-05-19T09:07:46", "url": "https://files.pythonhosted.org/packages/15/27/3330a343de80d6849545b6c7723f8c9a08b4b104de964ac366e7e6b318df/dumptruck-0.1.6.tar.gz" } ] }