26
26
config .optionxform = str # don't lowercase DSNs
27
27
config .read (config_file , encoding = 'utf-8' )
28
28
try :
29
- os .environ .update (config ['Environment ' ])
29
+ os .environ .update (config ['environment ' ])
30
30
except KeyError :
31
31
pass
32
32
@@ -44,7 +44,7 @@ def create(self):
44
44
+ dbms_types , ** widget_defaults )
45
45
46
46
try :
47
- dsns = ['...' ] + [f'{ index + 1 } . { item } ' for index , item in enumerate (config ['DSN ' ])]
47
+ dsns = ['...' ] + [f'{ index + 1 } . { item } ' for index , item in enumerate (config ['dsn ' ])]
48
48
except KeyError :
49
49
dsns = ['...' ]
50
50
self .dsn = self .add (TitleCombo , name = '- DSN:' , value = 0 , values = dsns ,
@@ -105,9 +105,9 @@ def on_ok(self): # NOSONAR
105
105
notify_confirm ('User is mandatory!' , title = 'ERROR' , editw = True )
106
106
return
107
107
108
- dbtype = dbms_types [self .dbtype .value - 1 ]
108
+ dbtype = dbms_types [self .dbtype .value - 1 ]. lower ()
109
109
try :
110
- dsn = config ['DSN ' ][list (config ['DSN ' ])[self .dsn .value - 1 ]]
110
+ dsn = config ['dsn ' ][list (config ['dsn ' ])[self .dsn .value - 1 ]]
111
111
except KeyError :
112
112
dsn = ''
113
113
host = self .host .value or 'localhost'
@@ -123,67 +123,48 @@ def on_ok(self): # NOSONAR
123
123
prompt = section .get ('prompt' , '' )[1 :- 1 ]
124
124
startup_file = section .get ('startup_file' , '' )
125
125
sqlhelp = section .get ('help' )
126
- legacy = section .get ('legacy' )
127
126
128
127
# CONNECTION PARAMETERS AND OPTIONS
129
128
opts = []
130
129
env_vars = {}
131
130
132
- if dbtype == 'MSSQL ' :
131
+ if dbtype == 'mssql ' :
133
132
port = self .port .value or 1433
134
133
conn_params = ['-U' , user , '-P' , passwd , '-S' , '{host},{port}' , '-d' , db ]
135
134
136
- if legacy :
137
- defshell = 'sqlcmd'
138
- opts = ['-N' , '-C' ]
139
- env_vars = {'SQLCMDINI' : startup_file }
135
+ if pycompat .system .is_windows :
136
+ defshell = 'mssql-cli.bat'
140
137
else :
141
- if pycompat .system .is_windows :
142
- defshell = 'mssql-cli.bat'
143
- else :
144
- defshell = 'mssql-cli'
145
- # `-N -C` = "encrypt, trust server certificate" (NOSONAR)
146
- opts = ['-N' , '-C' , '--mssqlclirc' , startup_file ]
138
+ defshell = 'mssql-cli'
139
+ # `-N -C` = "encrypt, trust server certificate" (NOSONAR)
140
+ opts = ['-N' , '-C' , '--mssqlclirc' , startup_file ]
147
141
148
142
# named pipe connection to LocalDB
149
143
if tb .is_localdb (dsn ) or tb .is_localdb (host ):
150
144
conn_params [5 ] = '{host}' # host,port -> host
151
145
opts .remove ('-N' ) # `-N` = "encrypt" (NOSONAR)
152
146
153
- elif dbtype == 'MySQL ' :
147
+ elif dbtype == 'mysql ' :
154
148
port = self .port .value or 3306
155
149
conn_params = ['-u' , user , '-h' , '{host}' , '-P' , '{port}' , '-D' , db ]
156
150
157
- if legacy :
158
- defshell = 'mysql'
159
- opts = ['--protocol=TCP' ]
160
- if startup_file :
161
- # `--defaults-file` must be first option
162
- opts = [f'--defaults-file={ startup_file } ' ] + opts
163
-
164
- else :
165
- defshell = 'mycli'
166
- if startup_file :
167
- opts = ['--myclirc' , startup_file ]
151
+ defshell = 'mycli'
152
+ if startup_file :
153
+ opts = ['--myclirc' , startup_file ]
168
154
169
155
if passwd :
170
156
conn_params += [f'-p{ passwd } ' ]
171
157
172
- elif dbtype == 'Oracle ' :
158
+ elif dbtype == 'oracle ' :
173
159
port = self .port .value or 1521
174
160
conn_params = [f'{ user } /{ passwd } @//{{host}}:{{port}}' ]
175
161
176
- if legacy :
177
- defshell = 'sqlplus'
178
- opts = ['-l' ]
179
- env_vars = {'SQLPATH' : '' }
162
+ if pycompat .system .is_windows :
163
+ defshell = 'sql.exe'
180
164
else :
181
- if pycompat .system .is_windows :
182
- defshell = 'sql.exe'
183
- else :
184
- defshell = 'sql'
185
- opts = ['-logon' ]
186
- env_vars = {'SQLPATH' : startup_file }
165
+ defshell = 'sql'
166
+ opts = ['-logon' ]
167
+ env_vars = {'SQLPATH' : startup_file }
187
168
188
169
if db :
189
170
# SQLcl can't handle `user@host/` connection strings
@@ -192,20 +173,16 @@ def on_ok(self): # NOSONAR
192
173
if user == 'sys' :
193
174
conn_params += ['as' , 'sysdba' ]
194
175
195
- elif dbtype == 'PostgreSQL ' :
176
+ elif dbtype == 'postgresql ' :
196
177
port = self .port .value or 5432
197
178
conn_params = [f'postgres://{ user } :{ passwd } @{{host}}:{{port}}/{ db } ' ]
198
179
199
- if legacy :
200
- defshell = 'psql'
201
- env_vars = {'PSQLRC' : startup_file }
202
- else :
203
- defshell = 'pgcli'
204
- opts = ['--pgclirc' , startup_file ]
205
- if prompt :
206
- opts += ['--prompt' , prompt ]
180
+ defshell = 'pgcli'
181
+ opts = ['--pgclirc' , startup_file ]
182
+ if prompt :
183
+ opts += ['--prompt' , prompt ]
207
184
208
- elif dbtype == 'SQLite ' :
185
+ elif dbtype == 'sqlite ' :
209
186
# don't start tunnel for SQLite
210
187
host = None
211
188
port = None
@@ -216,14 +193,10 @@ def on_ok(self): # NOSONAR
216
193
else :
217
194
conn_params = [db ]
218
195
219
- if legacy :
220
- defshell = 'sqlite3'
221
- opts = ['-init' , startup_file ]
222
- else :
223
- defshell = 'litecli'
224
- opts = ['--liteclirc' , startup_file ]
225
- if prompt :
226
- opts += ['--prompt' , prompt ]
196
+ defshell = 'litecli'
197
+ opts = ['--liteclirc' , startup_file ]
198
+ if prompt :
199
+ opts += ['--prompt' , prompt ]
227
200
228
201
# noinspection PyUnboundLocalVariable
229
202
sqlshell = section .get ('shell' , defshell )
@@ -234,7 +207,7 @@ def on_ok(self): # NOSONAR
234
207
port = None
235
208
236
209
# DSNs have precedence over manually entered connection parameters
237
- if dbtype == 'SQLite ' :
210
+ if dbtype == 'sqlite ' :
238
211
conn_params = [dsn ]
239
212
else :
240
213
conn_params = dsn .split ()
0 commit comments