Parcourir la source

Updating functionality of insert method

ogert il y a 4 ans
Parent
commit
130606924a
1 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 5 3
      cdplib/db_handlers/MongodbHandler.py

+ 5 - 3
cdplib/db_handlers/MongodbHandler.py

@@ -233,10 +233,12 @@ class MongodbHandler:
             if (len(data) == 1) or (isinstance(data, dict)):
 
                 if isinstance(data, pd.DataFrame) and (len(data) == 1):
-                    data = data.iloc[0]
+                    insert_data = data.iloc[0]
                 elif type(data) is list:
-                    data = data[0]
-                self._database[collection_name].insert_one(data)
+                    insert_data = data[0]
+                else:
+                    insert_data = data
+                self._database[collection_name].insert_one(insert_data)
             else:
                 self._database[collection_name].insert_many(data, ordered=ordered)