Commit 18639ac 1 parent 9dab0b5 commit 18639ac Copy full SHA for 18639ac
File tree 2 files changed +20
-13
lines changed
sqlalchemy_iris/intersystems
2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change 1
1
import re
2
- import pkg_resources
3
2
from ..base import IRISDialect
4
3
from sqlalchemy import text , util
5
4
from ..base import IRISExecutionContext
@@ -62,6 +61,8 @@ class IRISDialect_intersystems(IRISDialect):
62
61
63
62
logfile = None
64
63
64
+ server_version = None
65
+
65
66
def __init__ (self , logfile : str = None , ** kwargs ):
66
67
self .logfile = logfile
67
68
IRISDialect .__init__ (self , ** kwargs )
@@ -115,19 +116,21 @@ def create_connect_args(self, url):
115
116
116
117
return ([], opts )
117
118
119
+ def on_connect (self ):
120
+ super_ = super ().on_connect ()
121
+
122
+ def on_connect (conn ):
123
+ if super_ is not None :
124
+ super_ (conn )
125
+
126
+ server_version = dbapi .createIRIS (conn ).classMethodValue ("%SYSTEM.Version" , "GetNumber" )
127
+ server_version = server_version .split ("." )
128
+ self .server_version = tuple ([int ("" .join (filter (str .isdigit , v ))) for v in server_version ])
129
+
130
+ return on_connect
131
+
118
132
def _get_server_version_info (self , connection ):
119
- # get the wheel version from iris module
120
- try :
121
- return tuple (
122
- map (
123
- int ,
124
- pkg_resources .get_distribution (
125
- "intersystems_irispython"
126
- ).version .split ("." ),
127
- )
128
- )
129
- except : # noqa
130
- return None
133
+ return self .server_version
131
134
132
135
def _get_option (self , connection , option ):
133
136
with connection .cursor () as cursor :
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ def connect(*args, **kwargs):
15
15
return iris .connect (* args , ** kwargs )
16
16
17
17
18
+ def createIRIS (* args , ** kwargs ):
19
+ return iris .createIRIS (* args , ** kwargs )
20
+
21
+
18
22
# globals
19
23
apilevel = "2.0"
20
24
threadsafety = 0
You can’t perform that action at this time.
0 commit comments