Rename column/value read/write attributes to be consistent

This commit is contained in:
XANTRONIX Industrial 2025-02-17 10:58:24 -05:00
parent dc107537a4
commit 38911cb694
3 changed files with 7 additions and 7 deletions

View file

@ -27,7 +27,7 @@ class DatabaseTable():
values[k] += 1 values[k] += 1
def __format_columns_select__(self): def __format_columns_select__(self):
csel = getattr(self, '__columns_select__') csel = getattr(self, '__columns_read__')
if csel is None: if csel is None:
return self.__columns__ return self.__columns__
@ -59,7 +59,7 @@ class DatabaseTableCursor():
return fn(row) return fn(row)
obj = self.table() obj = self.table()
cr = getattr(self.table, '__columns_read__', None) cr = getattr(self.table, '__values_read__', None)
for name in self.table.__columns__: for name in self.table.__columns__:
try: try:
@ -217,7 +217,7 @@ class Database():
return cr return cr
def query(self, table, values=dict(), order_by=list()): def query(self, table, values=dict(), order_by=list()):
selectors = getattr(table, '__columns_select__', None) selectors = getattr(table, '__columns_read__', None)
if selectors is None: if selectors is None:
columns = table.__columns__ columns = table.__columns__

View file

@ -53,11 +53,11 @@ class Radar(DatabaseTable):
'call', 'wban', 'name', 'coord', 'site_elevation', 'tower_height' 'call', 'wban', 'name', 'coord', 'site_elevation', 'tower_height'
) )
__columns_select__ = { __columns_read__ = {
'coord': 'ST_AsText(coord) as coord' 'coord': 'ST_AsText(coord) as coord'
} }
__columns_read__ = { __values_read__ = {
'coord': Coord.from_wkt 'coord': Coord.from_wkt
} }

View file

@ -96,12 +96,12 @@ class StormReport(DatabaseTable):
'tornado_f_rating', 'coord_start', 'coord_end' 'tornado_f_rating', 'coord_start', 'coord_end'
) )
__columns_select__ = { __columns_read__ = {
'coord_start': 'ST_AsText(coord_start) as coord_start', 'coord_start': 'ST_AsText(coord_start) as coord_start',
'coord_end': 'ST_AsText(coord_end) as coord_end' 'coord_end': 'ST_AsText(coord_end) as coord_end'
} }
__columns_read__ = { __values_read__ = {
'timestamp_start': datetime.datetime.fromisoformat, 'timestamp_start': datetime.datetime.fromisoformat,
'timestamp_end': datetime.datetime.fromisoformat, 'timestamp_end': datetime.datetime.fromisoformat,
'coord_start': Coord.from_wkt, 'coord_start': Coord.from_wkt,