|
@@ -2,7 +2,7 @@
|
2
|
2
|
|
3
|
3
|
from leobject.datasources.dummy import DummyDatasource
|
4
|
4
|
from mosql.db import Database, all_to_dicts
|
5
|
|
-from mosql.query import select
|
|
5
|
+from mosql.query import select, insert
|
6
|
6
|
from leobject import REL_SUB, REL_SUP
|
7
|
7
|
|
8
|
8
|
from Lodel.utils.mosql import *
|
|
@@ -32,8 +32,14 @@ class LeDataSourceSQL(DummyDatasource):
|
32
|
32
|
# @param leclass LeClass
|
33
|
33
|
# @param datas dict : dictionnary of field:value pairs to save
|
34
|
34
|
# @return int : lodel_id of the created object
|
35
|
|
- def insert(self, letype, leclass, **datas):
|
36
|
|
- pass
|
|
35
|
+ def insert(self, letype, leclass, datas):
|
|
36
|
+ query_table_name = leclass.name
|
|
37
|
+ #building the query
|
|
38
|
+ query = insert(query_table_name, datas)
|
|
39
|
+ #executing the query
|
|
40
|
+ with self.db as cur:
|
|
41
|
+ cur.execute(query)
|
|
42
|
+ return True
|
37
|
43
|
|
38
|
44
|
## @brief delete an existing object
|
39
|
45
|
# @param letype LeType
|
|
@@ -81,10 +87,11 @@ class LeDataSourceSQL(DummyDatasource):
|
81
|
87
|
query = select(query_table_name, where=where_filters, select=field_list)
|
82
|
88
|
|
83
|
89
|
# Executing the query
|
84
|
|
- self.db.execute(query)
|
|
90
|
+ with self.db as cur:
|
|
91
|
+ results = cur.execute(query)
|
85
|
92
|
|
86
|
93
|
# Returning it as a list of dict
|
87
|
|
- return all_to_dicts(self.db)
|
|
94
|
+ return all_to_dicts(results)
|
88
|
95
|
|
89
|
96
|
# @brief prepares the filters to be used by the mosql library's functions
|
90
|
97
|
# @params filters : (FIELD, OPERATOR, VALUE) tuples
|