File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 5
5
Using JSON as very lightweight database
6
6
7
7
``` python
8
- >> > db = client.create_database(' table_1' )
9
- >> > db.add([{
10
- ... " id" : " 1001" ,
11
- ... " type" : " Regular"
12
- ... }, {
8
+ >> > db = Database()
9
+ >> > db.load(' output.json' ) # Load database from file
10
+ >> > db.add([{ # Add items what you want to add
13
11
... " id" : " 1002" ,
14
12
... " type" : " Chocolate"
15
13
... })
16
14
[' FqkmbYFSCRCAHQWydhM69v' , ' RUJGcVBFANvNRReXa8U3En' ]
17
- >> > db.save(json_kwds = {' indent' : 4 })
15
+ >> > db.save(' output.json ' , json_kwds = {' indent' : 4 }) # Just save it into file.
18
16
```
19
17
20
18
```js
21
- // table_1 .json
19
+ // output .json
22
20
{
23
21
" created_at" : " 2022-12-25T16:50:02.459068" ,
24
22
" creator" : " json_as_db" ,
@@ -32,7 +30,7 @@ Using JSON as very lightweight database
32
30
" type" : " Chocolate"
33
31
}
34
32
},
35
- " updated_at" : " 2022-12-25T16 :51:36.276790" ,
33
+ " updated_at" : " 2022-12-28T16 :51:36.276790" ,
36
34
" version" : " 1.0.0"
37
35
}
38
36
```
You can’t perform that action at this time.
0 commit comments