Browse Source

[#61] started the implementation of the update method in LeDataSourceSQL object

Roland Haroutiounian 9 years ago
parent
commit
16e3b2c210
1 changed files with 12 additions and 2 deletions
  1. 12
    2
      leobject/datasources/ledatasourcesql.py

+ 12
- 2
leobject/datasources/ledatasourcesql.py View File

3
 import sqlite3
3
 import sqlite3
4
 from leobject.datasources.dummy import DummyDatasource
4
 from leobject.datasources.dummy import DummyDatasource
5
 from mosql.db import Database, all_to_dicts
5
 from mosql.db import Database, all_to_dicts
6
-from mosql.query import select, insert
6
+from mosql.query import select, insert, update, delete
7
 from leobject import REL_SUB, REL_SUP
7
 from leobject import REL_SUB, REL_SUP
8
 
8
 
9
 from Lodel.utils.mosql import *
9
 from Lodel.utils.mosql import *
28
     # @param data dict
28
     # @param data dict
29
     # @return bool
29
     # @return bool
30
     def update(self, letype, leclass, filters, rel_filters, data):
30
     def update(self, letype, leclass, filters, rel_filters, data):
31
-        pass
31
+
32
+        query_table_name = leclass.name
33
+        where_filters = filters
34
+        set_data = data
35
+
36
+        # Building the query
37
+        query = update(table=query_table_name, where=where_filters, set=set_data)
38
+        # Executing the query
39
+        with self.db as cur:
40
+            cur.execute(query)
41
+        return True
32
 
42
 
33
     ## @brief create a new object in the datasource
43
     ## @brief create a new object in the datasource
34
     # @param letype LeType
44
     # @param letype LeType

Loading…
Cancel
Save