Skip to content

Commit 07c34ca

Browse files
committed
fixed query, added vacuum, updates & optimizations
1 parent 422adeb commit 07c34ca

File tree

6 files changed

+213
-111
lines changed

6 files changed

+213
-111
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ db_table.insert([{"name": "whothere", "password": "ohyeah"}, {"name": "whothere"
112112
db_table.find_row(5)
113113
db_table.update_row(300, {'name': 'bob'})
114114
db_table.delete_row(445)
115-
db_table.find_by_column_value("name", "bob")
115+
db_table.query({"name": "bob"})
116116
f = db_table.scan()
117117
f.__next__()
118118

changelog.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Changelog#
2+
## 2020-12-05 ##
3+
4+
* Fixed method `Table.__return_query` so now querying by `tbl.query({"name": "Bob"})` works correctly. Expanded capability (read bellow). Backward compatibility left. **Note**: Value strings are Case Sensitive!
5+
* Make compatible with full python (windows, linux).
6+
* Table creattion method inherit `rows_per_page` and `max_rows` from database schema settings.
7+
* Do not increase `tbl.current_row` counter if data has not passed validation yet.
8+
* New method `tbl.vacuum()` to optimize pagefiles. Worth to use after some data has been deleted.
9+
* updated method `Table.__return_query` so now is possible to search by multiple keys and values. Imagine following **persons_table** data:
10+
| fname | lname | age |
11+
|---|---|---|
12+
| John | Smith | 37 |
13+
| Nicole | Smith | *None* |
14+
| Kim | Smith| 7 |
15+
| John | Lee | *None* |
16+
| Nicole | Lee | 32 |
17+
| Bart | Lee | 3 |
18+
We want to get John and Nicole Smiths, but dont want all Smiths and no Lees. Following query `tbl.query({"fname":["John", "Nicole"], "lname": "Smith"})` and here is the result:
19+
``` python
20+
[{'fname': 'John', 'lname': 'Smith', 'age': 34},
21+
{'fname': 'Nicole', 'lname': 'Smith', 'age': None}]
22+
```
23+
You may add any number of search parameter in your query and all of them will be `AND`. In sql definition upper search query represent following SQL:
24+
```sql
25+
select * from persons_table where fname in ("John", "Nicole") and lname = "Smith"
26+
```
27+
* Changed `__insert_modify_data_file` so writing to files would be more efficient and faster in exchange in reliability if something unexpected happens.
28+
* Annotated all function's parameters
29+
* Fixed `tests/test.py` file to correcttly calculatee current row in `check_current_row()` function
30+
31+
`test/test.py` and `device_test.py` passed succesfully on
32+
> MicroPython v1.9.4-2922-gce1dfde98-dirty on 2020-11-26; ESP32 module with ESP32

device_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
exec(f.read(), globals())
88
"""
99

10-
import mdb
10+
import micropydatabase as mdb
1111
import gc
1212
import time
1313

0 commit comments

Comments
 (0)