File tree 3 files changed +32
-0
lines changed
3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,5 @@ def acmcli():
56
56
officerships_list (acmlib , args )
57
57
elif args .subparser2 == 'delete' :
58
58
officerships_delete (acmlib , args )
59
+ elif args .subparser1 == 'database' :
60
+ database_get (acmlib , args )
Original file line number Diff line number Diff line change @@ -193,4 +193,11 @@ def datetime_type(x):
193
193
194
194
officerships_delete_parser .add_argument ('officership_id' , type = int )
195
195
196
+
197
+ #
198
+ # Database Parser
199
+ #
200
+
201
+ database_parser = subparsers .add_parser ('database' )
202
+
196
203
parser .parse_args ()
Original file line number Diff line number Diff line change 1
1
import sys
2
+ import os
2
3
3
4
def exit_with_message_on_errors (f ):
4
5
@@ -234,3 +235,25 @@ def officerships_delete(acmlib, args):
234
235
235
236
acmlib .delete_officership (args .officership_id )
236
237
238
+ @exit_with_message_on_errors
239
+ def database_get (acmlib , args ):
240
+
241
+ database = acmlib .get_database ();
242
+
243
+ command = "psql "
244
+ if database .dilect :
245
+ command += "{}://" .format (database .dilect )
246
+ if database .username :
247
+ command += database .username
248
+ if database .password :
249
+ command += ":" + database .password
250
+ command += "@"
251
+ if database .host :
252
+ command += database .host
253
+ if database .port :
254
+ command += ":" + str (database .port )
255
+ if database .database :
256
+ command += "/" + database .database
257
+
258
+ os .system (command )
259
+
You can’t perform that action at this time.
0 commit comments