@@ -74,7 +74,7 @@ def flatten_dict(dictionary: dict, root_key: str = "", separator: str = "/"):
7474 """
7575 items = []
7676 for key , value in dictionary .items ():
77- new_key = root_key + separator + key if root_key else key
77+ new_key = str ( root_key ) + str ( separator ) + str ( key ) if root_key else key
7878 if isinstance (value , MutableMapping ):
7979 items .extend (
8080 TraitsDB .flatten_dict (value , new_key , separator = separator ).items ()
@@ -132,7 +132,7 @@ def get(self, table, cols="*", condition=None, **kwargs):
132132 for (k , v ) in kwargs .items ()
133133 }
134134 condition = " AND " .join ([f"{ k } ={ v } " for (k , v ) in escaped_kwargs .items ()])
135- get_row_query = f"SELECT { cols } FROM { table } WHERE { condition } ;"
135+ get_row_query = f"SELECT { cols } FROM [ { table } ] WHERE { condition } ;"
136136 response = self .execute (get_row_query )
137137
138138 if response is None :
@@ -158,7 +158,7 @@ def put_path_id(self, path):
158158 get_row_query = f"SELECT id FROM path WHERE path = '{ path } ' LIMIT 1;"
159159 res = self .execute (get_row_query ).fetchone ()
160160 if res :
161- return res [0 ]
161+ return res ["id" ]
162162 # create
163163 self .put ("path" , path = path )
164164 path_id = self .get ("path" , path = path , cols = "id" )["id" ]
@@ -334,10 +334,9 @@ def add_pathpair(self, pair: PathPair):
334334
335335 # get element type for list
336336 # add: handle lists with mixed element type
337- t = type (v [0 ]) if isinstance (v , list ) else type (v )
337+ t = type (v [0 ]) if isinstance (v , list ) and len ( v ) > 0 else type (v )
338338 k = f"{ k } /{ TraitsDB .sql_type (t )} "
339339 if k not in self .traits :
340- t = type (v [0 ]) if isinstance (v , list ) else type (v )
341340 self .create_trait_table (k , t )
342341 if k in self .traits :
343342 # add to list
0 commit comments