summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--coverage/numbits.py7
-rw-r--r--doc/dbschema.rst12
3 files changed, 17 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 996b7d4f..b0f3ccf1 100644
--- a/Makefile
+++ b/Makefile
@@ -124,6 +124,7 @@ docreqs:
tox -q -e doc --notest
dochtml: docreqs
+ .tox/doc/bin/python doc/check_copied_from.py doc/*.rst
$(SPHINXBUILD) -b html doc doc/_build/html
@echo
@echo "Build finished. The HTML pages are in doc/_build/html."
diff --git a/coverage/numbits.py b/coverage/numbits.py
index 4b340c8e..504452d7 100644
--- a/coverage/numbits.py
+++ b/coverage/numbits.py
@@ -150,10 +150,11 @@ def register_sqlite_functions(connection):
conn = sqlite3.connect('example.db')
register_sqlite_functions(conn)
c = conn.cursor()
+ # Kind of a nonsense query: find all the files and contexts that
+ # executed line 47 in any file:
c.execute(
- "select lb.file_id, lb.context_id from line_bits lb"
- "where num_in_numbits(?, lb.numbits)",
- (interesting_line_number,)
+ "select file_id, context_id from line_bits where num_in_numbits(?, numbits)",
+ (47,)
)
"""
connection.create_function("numbits_union", 2, numbits_union)
diff --git a/doc/dbschema.rst b/doc/dbschema.rst
index c57de92e..34f4a92e 100644
--- a/doc/dbschema.rst
+++ b/doc/dbschema.rst
@@ -14,6 +14,18 @@ For most needs, the :class:`.CoverageData` API will be sufficient, and should
be preferred to accessing the database directly. Only advanced uses will need
to use the database.
+The schema can change without changing the major version of coverage.py, so be
+careful when accessing the database directly. The `coverage_schema` table has
+the schema number of the database. The schema described here corresponds to:
+
+.. copied_from: coverage/sqldata.py
+
+.. code::
+
+ SCHEMA_VERSION = 7
+
+.. end_copied_from
+
You can use SQLite tools such as the :mod:`sqlite3 <python:sqlite3>` module in
the Python standard library to access the data. Some data is stored in a
packed format that will need custom functions to access. See