3
3
4
4
import gtk
5
5
import geany
6
- import sqlanydb
6
+
7
+
8
+ try :
9
+ import sqlanydb
10
+ sqla = True
11
+ except :
12
+ sqla = False
13
+
14
+
15
+
7
16
8
17
class GeanyPySQLDB ():
9
18
@@ -36,7 +45,7 @@ def connect(self):
36
45
self .connection = sqlanydb .connect ( userid = self .userid ,
37
46
password = self .password ,
38
47
server = self .server )
39
-
48
+
40
49
def disconnect (self ):
41
50
if self .connection is not None :
42
51
self .connection .close ()
@@ -48,15 +57,15 @@ class GeanyPySQL(geany.Plugin):
48
57
__plugin_version__ = "0.1"
49
58
__plugin_description__ = "Making an SQL client out of Geany"
50
59
__plugin_author__ = "Frank Lanitz <frank@frank.uvena.de>"
51
-
60
+
52
61
db = None
53
62
cursor = None
54
63
55
64
def __init__ (self ):
56
-
57
- # Logging
65
+
66
+ # Logging
58
67
geany .Plugin .__init__ (self )
59
-
68
+
60
69
# Adding menu entries
61
70
# Add main menu entry for pluin and show it
62
71
self .root_menu = gtk .MenuItem ("_GeanyPySQL" )
@@ -72,11 +81,11 @@ def __init__(self):
72
81
# Now adding items to submenu
73
82
mi_connect = gtk .MenuItem ("_Connect" )
74
83
plugin_menu .append (mi_connect )
75
-
84
+
76
85
mi_disconnect = gtk .MenuItem ("_Disconnect" )
77
86
plugin_menu .append (mi_disconnect )
78
-
79
- # And callbacks
87
+
88
+ # And callbacks
80
89
mi_connect .connect ("activate" , self .on_click_connect , None )
81
90
mi_disconnect .connect ("activate" , self .on_click_disconnect , None )
82
91
@@ -88,7 +97,7 @@ def cleanup(self):
88
97
def on_click_connect (self , widget , data ):
89
98
self .db = GPS_sqlanywhere (uid = 'dba' , pwd = 'sql' , server = 'foo' )
90
99
self .db .connect ()
91
-
100
+
92
101
def on_click_disconnect (self , widget , data ):
93
102
self .db .disconnect ()
94
103
0 commit comments