88import imp
99import logging
1010import os
11+ import re
1112import sys
1213import traceback
1314import warnings
@@ -41,7 +42,12 @@ def getSafeExString(ex, encoding=None): # Cross-referenced function
4142class SQLAlchemy (GenericConnector ):
4243 def __init__ (self , dialect = None ):
4344 GenericConnector .__init__ (self )
45+
4446 self .dialect = dialect
47+ self .address = conf .direct
48+
49+ if self .dialect :
50+ self .address = re .sub (r"\A.+://" , "%s://" % self .dialect , self .address )
4551
4652 def connect (self ):
4753 if _sqlalchemy :
@@ -52,18 +58,15 @@ def connect(self):
5258 if not os .path .exists (self .db ):
5359 raise SqlmapFilePathException ("the provided database file '%s' does not exist" % self .db )
5460
55- _ = conf .direct .split ("//" , 1 )
56- conf .direct = "%s////%s" % (_ [0 ], os .path .abspath (self .db ))
57-
58- if self .dialect :
59- conf .direct = conf .direct .replace (conf .dbms , self .dialect , 1 )
61+ _ = self .address .split ("//" , 1 )
62+ self .address = "%s////%s" % (_ [0 ], os .path .abspath (self .db ))
6063
6164 if self .dialect == "sqlite" :
62- engine = _sqlalchemy .create_engine (conf . direct , connect_args = {"check_same_thread" : False })
65+ engine = _sqlalchemy .create_engine (self . address , connect_args = {"check_same_thread" : False })
6366 elif self .dialect == "oracle" :
64- engine = _sqlalchemy .create_engine (conf . direct )
67+ engine = _sqlalchemy .create_engine (self . address )
6568 else :
66- engine = _sqlalchemy .create_engine (conf . direct , connect_args = {})
69+ engine = _sqlalchemy .create_engine (self . address , connect_args = {})
6770
6871 self .connector = engine .connect ()
6972 except (TypeError , ValueError ):
0 commit comments