[gevice] enable Foreign Key support in sqlite3.
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] enable Foreign Key support in sqlite3.
- Date: Sat, 12 Nov 2011 13:16:00 +0000 (UTC)
commit d0d55ccc9168209d112ad95704e64623c5269d08
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Sat Nov 12 10:15:47 2011 -0300
enable Foreign Key support in sqlite3.
ChangeLog | 4 ++++
src/gevicedatabase.py | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fd7f639..e736b13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-11-12 Alejandro Valdes Jimenez <avaldes gnome org>
+ * src/gevicedatabase.py: add new functions for enable Foreign Key support in sqlite3.
+ * Fixed bug #663918
+
2011-11-11 Alejandro Valdes Jimenez <avaldes gnome org>
* src/gevice.py:
* Fixed bug #663868
diff --git a/src/gevicedatabase.py b/src/gevicedatabase.py
index e49f0e5..f4ee161 100644
--- a/src/gevicedatabase.py
+++ b/src/gevicedatabase.py
@@ -22,6 +22,9 @@ class GeviceDatabase:
gevice.connected_to_database = True
self.cur = self.conn.cursor()
+ if (self.if_enable_foreign_key() == False):
+ self.enable_foreign_key()
+
self.load_data_from_database(gevice)
action_open = gevice.actiongroup_window.get_action("Open")
@@ -40,6 +43,21 @@ class GeviceDatabase:
result = gevice.show_message (_("Unable to connect to the database"), Gtk.MessageType.ERROR, (Gtk.STOCK_OK, Gtk.ResponseType.OK), None)
return False
+ def enable_foreign_key (self):
+ self.cur.execute ("PRAGMA foreign_keys = ON ")
+ print "foreign_keys enabled..."
+
+ def if_enable_foreign_key(self):
+ self.cur.execute ("PRAGMA foreign_keys")
+ rows = self.cur.fetchall()
+
+ if (rows[0][0] == 0):
+ print "foreign_keys Not enabled..."
+ return False
+ else:
+ print "foreign_keys enabled..."
+ return True
+
def execute_sql_select (self,gevice,sql):
try:
self.cur.execute(sql)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]