Merge lp:~tribaal/u1db/u1db-docs-and-cleanup into lp:u1db

Proposed by Chris Glass
Status: Merged
Merged at revision: 277
Proposed branch: lp:~tribaal/u1db/u1db-docs-and-cleanup
Merge into: lp:u1db
Diff against target: 100 lines (+52/-5)
3 files modified
.bzrignore (+1/-0)
README (+49/-2)
u1db/backends/sqlite_backend.py (+2/-3)
To merge this branch: bzr merge lp:~tribaal/u1db/u1db-docs-and-cleanup
Reviewer Review Type Date Requested Status
John A Meinel (community) Approve
Review via email: mp+105379@code.launchpad.net

Description of the change

This branch adds a little substance to the README file, as well as correcting some small inefficiencies/omissions (unused variable, undefined references).

Please don't hesitate to be ruthless when reviewing this, since this is my first contribution to the project.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

Dependencies are also mentioned in setup.py under 'install_requires' and 'tests_require'.

The other tweaks seem fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-04-18 20:41:57 +0000
3+++ .bzrignore 2012-05-10 19:17:27 +0000
4@@ -10,3 +10,4 @@
5 html-docs/_build/html
6 u1db/tests/c_backend_wrapper.c
7 ./src/u1db_schema.c
8+.ropeproject
9
10=== modified file 'README'
11--- README 2011-12-20 12:15:00 +0000
12+++ README 2012-05-10 19:17:27 +0000
13@@ -1,8 +1,55 @@
14+Getting started
15+===============
16+
17+The easiest way to get started is to use "setup.py install", preferably
18+in a virtualenv (although that's up to you).
19+
20+
21+Using the database interface
22+============================
23+
24+Inserting and retrieving documents::
25+
26+ import u1db
27+ db = u1db.open(":memory:", create=True)
28+ doc = db.create_doc('{"firstname": "Bob", "familyname": "Foo"}')
29+ print "document id: %s" % doc.doc_id
30+ print "document revision: %s" % doc.revision
31+
32+ doc2 = db.get_doc(doc.doc_id)
33+ print (doc == doc2)
34+
35+Creating an index::
36+
37+ import u1db
38+ db = u1db.open(":memory:", create=True)
39+ # Indexes can be on a single field...
40+ idx = db.create_index("firstname_idx", ["firstname"])
41+ # ... or on several
42+ idx2 = db_create_index("composed_idx", ["firstname", "familyname"])
43+
44+Querying using an index::
45+
46+ import u1db
47+ db = u1db.open(":memory:", create=True)
48+ doc = db.get_from_index("firstname_idx", [("Bob",)])
49+ print doc
50+ # You can of course get a range of documents using wildcards
51+ docs = db.get_from_index("firstname_idx", [("Bo*",)])
52+
53+More information and comments can be found in the u1db/__init__.py file.
54+
55+
56+Running the tests
57+=================
58+
59+A simple `make check` should get you on the right tracks. The dependencies can
60+be infered from the output.
61+
62+
63 Building the docs
64 =================
65
66 cd html-docs
67 make doctest # check that the code examples all still work
68 make html # build HTML documentation at _build/html/index.html
69-
70-
71
72=== modified file 'u1db/backends/sqlite_backend.py'
73--- u1db/backends/sqlite_backend.py 2012-04-27 14:22:47 +0000
74+++ u1db/backends/sqlite_backend.py 2012-05-10 19:17:27 +0000
75@@ -130,7 +130,7 @@
76 try:
77 c.execute("SELECT value FROM u1db_config"
78 " WHERE name = 'sql_schema'")
79- except dbapi2.OperationalError, e:
80+ except dbapi2.OperationalError:
81 # The table does not exist yet
82 val = None
83 else:
84@@ -583,7 +583,7 @@
85 c.execute(SQL_INDEX_KEYS, (index,))
86 except dbapi2.OperationalError, e:
87 raise dbapi2.OperationalError(str(e) +
88- '\nstatement: %s\nargs: %s\n' % (statement, args))
89+ '\nstatement: %s\nargs: %s\n' % (SQL_INDEX_KEYS, (index,)))
90 res = c.fetchall()
91 return [r[0] for r in res]
92
93@@ -622,7 +622,6 @@
94 return set([x[0] for x in c.fetchall()])
95
96 def _evaluate_index(self, raw_doc, field):
97- val = raw_doc
98 parser = query_parser.Parser()
99 getter = parser.parse(field)
100 return getter.get(raw_doc)

Subscribers

People subscribed via source and target branches