File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed
sqlalchemy_iris/intersystems Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change 11import re
2- import pkg_resources
32from ..base import IRISDialect
43from sqlalchemy import text , util
54from ..base import IRISExecutionContext
@@ -62,6 +61,8 @@ class IRISDialect_intersystems(IRISDialect):
6261
6362 logfile = None
6463
64+ server_version = None
65+
6566 def __init__ (self , logfile : str = None , ** kwargs ):
6667 self .logfile = logfile
6768 IRISDialect .__init__ (self , ** kwargs )
@@ -115,19 +116,21 @@ def create_connect_args(self, url):
115116
116117 return ([], opts )
117118
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+
118132 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
131134
132135 def _get_option (self , connection , option ):
133136 with connection .cursor () as cursor :
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ def connect(*args, **kwargs):
1515 return iris .connect (* args , ** kwargs )
1616
1717
18+ def createIRIS (* args , ** kwargs ):
19+ return iris .createIRIS (* args , ** kwargs )
20+
21+
1822# globals
1923apilevel = "2.0"
2024threadsafety = 0
You can’t perform that action at this time.
0 commit comments