@@ -26,7 +26,7 @@ def __init__(self, debug=False):
2626 f = self ._get_file ('r' )
2727 self ._conn_dicts = []
2828 self .version = 0
29-
29+ self . _connection_format = "%s+%s://%s:%s@%s/%s"
3030
3131 # Read all lines (connections) in the connection.cfg file
3232 while True :
@@ -185,62 +185,30 @@ def _get_file(self, mode):
185185
186186 return config_file
187187
188- # def _build_connection_string(self, conn_dict):
189- # driver = ""
190- # connformat= self._connection_format
191- # if conn_dict['engine'] == 'mssql' and sys.platform != 'win32':
192- # driver = "pyodbc"
193- # quoted = urllib.quote_plus('DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict['address'], conn_dict['user'], conn_dict['password']))
194- # conn_string = 'mssql+pyodbc:///?odbc_connect={}'.format(quoted)
195- #
196- # else:
197- # if conn_dict['engine'] == 'mssql':
198- # driver = "pyodbc"
199- # connformat=self._connection_format = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+10.0"
200- # elif conn_dict['engine'] == 'mysql':
201- # driver = "pymysql"
202- # elif conn_dict['engine'] == 'postgresql':
203- # driver = "psycopg2"
204- # else:
205- # driver = "None"
206- #
207- # conn_string = connformat % (
208- # conn_dict['engine'], driver, conn_dict['user'], conn_dict['password'], conn_dict['address'],
209- # conn_dict['db'])
210- # return conn_string
211188 def _build_connection_string (self , conn_dict ):
212- # driver = ""
213- # print "****", conn_dict
214-
189+ driver = ""
190+ connformat = self ._connection_format
215191 if conn_dict ['engine' ] == 'mssql' and sys .platform != 'win32' :
216192 driver = "pyodbc"
217- #'DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict['address'], conn_dict['user'], conn_dict['password'])
218193 quoted = urllib .quote_plus ('DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict ['address' ], conn_dict ['user' ], conn_dict ['password' ]))
219194 conn_string = 'mssql+pyodbc:///?odbc_connect={}' .format (quoted )
195+
220196 else :
221- self ._connection_format = "%s+%s://%s:%s@%s/%s"
222197 if conn_dict ['engine' ] == 'mssql' :
223198 driver = "pyodbc"
224- #self._connection_format = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+10.0"
225- conn = "%s+%s://%s:%s@%s/%s?driver=SQL+Server"
226- if "sqlncli11.dll" in os .listdir ("C:\\ Windows\\ System32" ):
227- conn = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+11.0"
228- self ._connection_format = conn
199+ connformat = self ._connection_format = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+10.0"
229200 elif conn_dict ['engine' ] == 'mysql' :
230201 driver = "pymysql"
231202 elif conn_dict ['engine' ] == 'postgresql' :
232203 driver = "psycopg2"
233204 else :
234205 driver = "None"
235206
236- conn_string = self . _connection_format % (
207+ conn_string = connformat % (
237208 conn_dict ['engine' ], driver , conn_dict ['user' ], conn_dict ['password' ], conn_dict ['address' ],
238209 conn_dict ['db' ])
239-
240- # print "******", conn_string
241210 return conn_string
242211
243-
244212 def _save_connections (self ):
245213 f = self ._get_file ('w' )
246214 for conn in self ._conn_dicts :
0 commit comments