lmcmd
is an interactive console based on Python's code.InteractiveConsole
, supporting key-value database operations using LMDB
.
You can install it using pip
:
pip install lmcmd
- show: Display the current database name.
- set
<KEY>
<VALUE>
: Store key-value data. - get
<KEY>
: Retrieve the value of a specified key. - del
<KEY>
: Delete a specified key. - list: List all key-value pairs in the database.
- export: Export database data to
export.json
. - import
<ID>
<FILE_PATH>
: Import data from a JSON file. - search
<VALUE>
: List value in the database key or value.
After installation, you can run it directly from the command line:
lmcmd my_database
>>> set name Alice
Ok
>>> get name
Alice
>>> list
{name: Alice}
>>> export
Data Exported to export.json
>>> import id data.json
Data Imported!
>>> show
Database: my_database
>>> del name
Ok
>>> list
(Empty)
>>> search Alice
{name: Alice}
All data is stored in the LMDB
database. A KEY
must be provided for set/get/del
operations.
Use the export
command to save database data to export.json
.
import <ID> <FILE_PATH>
<ID>
: The unique identifier field for the imported data.<FILE_PATH>
: The path to the JSON data file.
If the JSON data is formatted as follows:
[
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
Executing import id data.json
will store the data using id
as the key.
- Python 3.8+
lmdb
This project is released under the MIT License.