From d240a45e77f6723ad618f5078342b69d050d6278 Mon Sep 17 00:00:00 2001 From: Gregor Aisch Date: Wed, 3 Apr 2013 00:24:23 +0200 Subject: [PATCH] docs --- docs/index.rst | 13 +++++++------ docs/quickstart.rst | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index ed29ca7..4acaddc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,11 +12,11 @@ dataset: databases for lazy people Although managing data in relational database has plenty of benefits, we find them rarely being used in the typical day-to-day work with small to medium scale datasets. But why is that? Why do we see an awful lot of data stored in static files in CSV or JSON format? -Because **good programmers are lazy**, and thus they tend to prefer the easiest solution they find. And managing data in a databases simply wasn't the simplest solution to store a bunch of structured data. This is where ``dataset`` steps in! +Because **programmers are lazy**, and thus they tend to prefer the easiest solution they find. And managing data in a databases simply wasn't the simplest solution to store a bunch of structured data. This is where ``dataset`` steps in! Dataset is here to **take the pain out of databases**. It makes reading and writing data in databases as simple as reading and writing JSON files. -In short, :: +:: import dataset @@ -25,7 +25,7 @@ In short, :: db['sometable'].insert(dict(name='Jane Doe', age=34, gender='female')) -Now look at `similar code, without dataset `_. +Here is `similar code, without dataset `_. Features @@ -33,10 +33,11 @@ Features * **Automatic schema**: If a table or column is written that does not exist in the database, it will be created automatically. -* **Upserts**: Records are either created or updated, depdending on +* **Upserts**: Records are either created or updated, depending on whether an existing version can be found. -* **Query helpers** for simple queries such as all rows in a table or - all distinct values across a set of columns. +* **Query helpers** for simple queries such as :py:meth:`all ` rows in a table or + all :py:meth:`distinct ` values across a set of columns. +* **Compatibility**: Being built on top of `SQLAlchemy `_, ``dataset`` works with all major databases, such as SQLite, PostgreSQL and MySQL. Contents -------- diff --git a/docs/quickstart.rst b/docs/quickstart.rst index ba9879e..c1ca514 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -69,14 +69,14 @@ Searching for specific entries:: # Returns all items table.find(country='China') -Querying data -------------- +Running custom SQL queries +-------------------------- -Querying data is easy. Dataset returns an iteratable result object:: +Of course the main reason you're using a database is that you want to use the full power of SQL queries. Here's how you run them using dataset:: - result = db.query('SELECT ...') - for row in result: - print row + result = db.query('SELECT country, COUNT(*) cnt FROM population GROUP BY year') + for row in res: + print row.country, row.cnt Freezing your data ------------------