Python dictionary backed by SQLite, includes fast text search and more advanced data structures
Project description
SearchDB
A SQLite powered dictionary
Features
- Indexed keys and values
- Can store dicts, lists, tuples as values (they are not indexed in that case)
- Multi column indexes
- Use SearchDB as a regular database, store several columns instead of just key-value
- If column is called "JSON" then datatypes can get stored there (they get converted to JSON)
- Fast Text Search
- Use Search functions to query large amounts of text.
- Uses FastTextSearch5 functions in SQLite
- Persists to file
- Makes sharing dicts easy
- .merge function merges two different databases with the same structure.
Usage
Basic usage
In [1]: import SearchDb
In [2]: db = SearchDb.SearchDb(":memory:") # Create an in memory database
In [3]: db["a"] = "alfa"
In [4]: db["a"]
Out[4]: 'alfa'
In [5]: del(db["a"])
In [6]: db["b"] = "beta"
In [7]: db.delete("b")
Store and search text data
- Use search_add("unindexed_key", "lots of text") to add large datasets
- Examples:
- Index a book, page is key, value is all text in page
Use custom indexes
To set a custom name for your regular key,value index use:
.table_in_use("newname")
To set a custom name for your text search index (one per book for example) use:
.search_table_in_use("python_for_noobs")
Create new table
To create a new table (database) use the .create_tables() function.
First set the name of the new table or tables you wish to create, for instance:
.table_in_use = "new_key_value"
.multi_table_in_use = "new_multi_column"
.create_tables() # Will now create all the new tables
.search_table_in_use = "new_indexed_texts"
.sdb.create_search_index()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SearchDb-1.0.1.tar.gz
(19.3 kB
view details)
File details
Details for the file SearchDb-1.0.1.tar.gz.
File metadata
- Download URL: SearchDb-1.0.1.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ccf894a5dba30a4c0996a72fed0c6fd678193a92a6906b701296160c718edb8
|
|
| MD5 |
212a9f3378643b46bf471684472ec0ec
|
|
| BLAKE2b-256 |
ae0eaefc7b7e4be35ad20ccfb7593eeea79613a6b4d515ab12149f2986396c46
|