Created
September 29, 2017 20:21
-
-
Save delijati/49f9b6c5d3e9eb79d7468226796900ba to your computer and use it in GitHub Desktop.
dataset + flatdict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flatdict | |
values = {'foo': {'bar': {'baz': 0, | |
'qux': 1, | |
'corge': 2}, | |
'grault': {'baz': 3, | |
'qux': 4, | |
'corge': 5}}, | |
'garply': {'foo': 0, 'bar': 1, 'baz': 2, 'qux': {'corge': 3}}} | |
flat = flatdict.FlatDict(values) | |
import dataset | |
db = dataset.connect('sqlite:///:memory:') | |
table = db['sometable'] | |
table.insert(flatdict.FlatDict(values)) | |
table.find_one(**{'foo:bar:corge': 2}) | |
flatdict.FlatDict(table.find_one(**{'foo:bar:corge': 2})).as_dict() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment