dblite
1.3.0
Simple query interface for SQL databases
|
Classes | |
class | StaticTzInfo |
datetime.tzinfo class representing a constant offset from UTC. More... | |
Functions | |
def | factory (ctor, data) |
Returns object constructed with data dictionary. More... | |
def | is_dataobject (obj) |
Returns whether input is a data object: namedtuple, or has attributes or slots. More... | |
def | is_namedtuple (obj) |
Returns whether input is a namedtuple class or instance. More... | |
def | json_dumps (data, indent=2, sort_keys=True) |
Returns JSON string, with datetime types converted to ISO-8601 strings (in UTC if no timezone set), sets converted to lists, and Decimal objects converted to float or int. More... | |
def | json_loads (s) |
Returns deserialized JSON, with datetime/date strings converted to objects. More... | |
def | keyvalues (obj, namefmt=None) |
Returns a list of keys and values, or [given object] if not applicable. More... | |
def | load_modules () |
Returns db engines loaded from file directory, as {name: module}. More... | |
def | nameify (val, namefmt=None, parent=None) |
Returns value as table or column name string. More... | |
def | parse_datetime (s) |
Tries to parse string as ISO8601 datetime, returns input on error. More... | |
Variables | |
UTC = StaticTzInfo("UTC", StaticTzInfo.ZERO) | |
UTC timezone singleton. More... | |
def dblite.util.factory | ( | ctor, | |
data | |||
) |
Returns object constructed with data dictionary.
ctor | callable like a class, declared args are matched case-insensitively for positional arguments if keyword argument invocation fails |
data | data dictionary with string keys |
def dblite.util.is_dataobject | ( | obj | ) |
def dblite.util.is_namedtuple | ( | obj | ) |
def dblite.util.json_dumps | ( | data, | |
indent = 2 , |
|||
sort_keys = True |
|||
) |
def dblite.util.json_loads | ( | s | ) |
def dblite.util.keyvalues | ( | obj, | |
namefmt = None |
|||
) |
Returns a list of keys and values, or [given object] if not applicable.
obj | mapping or namedtuple or list|set|tuple or object with attributes or slots |
namefmt | function(key) to apply on extracted keys, if any |
def dblite.util.load_modules | ( | ) |
def dblite.util.nameify | ( | val, | |
namefmt = None , |
|||
parent = None |
|||
) |
Returns value as table or column name string.
val | a primitive like string, or a named object like a class, or a class property or member or data descriptor |
namefmt | function(name) to apply on name extracted from class or object, if any |
parent | the parent class object if value is a class member or property |
def dblite.util.parse_datetime | ( | s | ) |
dblite.util.UTC = StaticTzInfo("UTC", StaticTzInfo.ZERO) |