diff --git a/docs/index.rst b/docs/index.rst index ff2f9b3..190780b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,11 +16,11 @@ Contents table -While the documentation is being constructed, enjoy an example instead: +While the full documentation is being constructed, enjoy an example: .. code-block:: python - from sqlite_utils import db + from sqlite_utils import Database import sqlite3 import requests import hashlib @@ -76,15 +76,16 @@ While the documentation is being constructed, enjoy an example instead: def hash_id(s): return hashlib.md5(s.encode("utf8")).hexdigest()[:5] - database = db.Database(sqlite3.connect("/tmp/ads3.db")) + database = Database(sqlite3.connect("/tmp/ads3.db")) ads = database["ads"] targets = database["targets"] ad_targets = database["ad_targets"] for ad in raw_ads: + ad_id = int(ad["file"].split(')')[-1].split(".")[0]) record = { - "id": ad["id"], + "id": ad_id, "file": ad["file"], "clicks": ad["clicks"], "impressions": ad["impressions"], @@ -107,7 +108,7 @@ While the documentation is being constructed, enjoy an example instead: ) ad_targets.insert({ "target_id": target_id, - "ad_id": ad["id"], + "ad_id": ad_id, }, foreign_keys=( ("ad_id", "INTEGER", "ads", "id"), ("target_id", "TEXT", "targets", "id"), diff --git a/sqlite_utils/__init__.py b/sqlite_utils/__init__.py index e69de29..c0e52e9 100644 --- a/sqlite_utils/__init__.py +++ b/sqlite_utils/__init__.py @@ -0,0 +1,3 @@ +from .db import Database + +__all__ = ["Database"] diff --git a/tests/test_create.py b/tests/test_create.py index 3ab62a1..876d2a1 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -1,4 +1,4 @@ -from sqlite_utils import db +from sqlite_utils import Database import json import sqlite3 import pytest @@ -6,7 +6,7 @@ import pytest @pytest.fixture def fresh_db(): - return db.Database(sqlite3.connect(":memory:")) + return Database(sqlite3.connect(":memory:")) def test_create_table(fresh_db): diff --git a/tests/test_introspect.py b/tests/test_introspect.py index 6ad178a..d791865 100644 --- a/tests/test_introspect.py +++ b/tests/test_introspect.py @@ -1,11 +1,11 @@ -from sqlite_utils import db +from sqlite_utils import Database import sqlite3 import pytest @pytest.fixture def existing_db(): - database = db.Database(sqlite3.connect(":memory:")) + database = Database(sqlite3.connect(":memory:")) database.conn.executescript( """ CREATE TABLE foo (text TEXT);