浏览代码

cmd_db: connect subcommand for postgresql

Daniel-Constantin Mierla 5 年之前
父节点
当前提交
3359d13e1b
共有 1 个文件被更改,包括 10 次插入6 次删除
  1. 10 6
      kamcli/commands/cmd_db.py

+ 10 - 6
kamcli/commands/cmd_db.py

@@ -108,9 +108,13 @@ def db_connect(ctx):
             ctx.gconfig.get("db", "rwpassword"),
             ctx.gconfig.get("db", "dbname"),
         )
-    elif dbtype == "postgres":
-        ctx.log("unsupported database type [%s]", dbtype)
-        sys.exit()
+    elif dbtype == "postgresql":
+        scmd = ("psql \"postgresql://{0}:{1}@{2}/{3}\"").format(
+            ctx.gconfig.get("db", "rwuser"),
+            ctx.gconfig.get("db", "rwpassword"),
+            ctx.gconfig.get("db", "host"),
+            ctx.gconfig.get("db", "dbname"),
+        )
     else:
         ctx.log("unsupported database type [%s]", dbtype)
         sys.exit()
@@ -131,7 +135,7 @@ def db_clirun(ctx, query):
             query,
             ctx.gconfig.get("db", "dbname"),
         )
-    elif dbtype == "postgres":
+    elif dbtype == "postgresql":
         ctx.log("unsupported database type [%s]", dbtype)
         sys.exit()
     else:
@@ -154,7 +158,7 @@ def db_clishow(ctx, table):
             table,
             ctx.gconfig.get("db", "dbname"),
         )
-    elif dbtype == "postgres":
+    elif dbtype == "postgresql":
         ctx.log("unsupported database type [%s]", dbtype)
         sys.exit()
     else:
@@ -177,7 +181,7 @@ def db_clishowg(ctx, table):
             table,
             ctx.gconfig.get("db", "dbname"),
         )
-    elif dbtype == "postgres":
+    elif dbtype == "postgresql":
         ctx.log("unsupported database type [%s]", dbtype)
         sys.exit()
     else: