summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith@newrelic.com>2014-12-13 08:04:48 -0800
committerAmjith Ramanujam <amjith@newrelic.com>2014-12-13 08:04:48 -0800
commitb03973782a9bc1141e7635ce573b1fdf1535d31d (patch)
treeeea3d8d9cf447688fcb28d137bd0ae8461263b5c
parent36cd848cadeec2dd93bbfe189964973b58304b67 (diff)
Fix a bug in postgres connection string.
-rw-r--r--TODO2
-rw-r--r--pgcli/pgexecute.py11
2 files changed, 3 insertions, 10 deletions
diff --git a/TODO b/TODO
index dbcd5ca8..62b25ec5 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-* [] postgres:// url is failing.
* [] Meta-enter to end the line not just semi-colon.
* [] Cmd-K breaks in OS X.
* [] Typing mid stream doesn't complete, only end of line is auto-completed.
@@ -21,6 +20,7 @@
* [ ] Detect a '.' and parse the word before it and get it's real name.
* [] Refactor the execution and output into a separate class.
* [] Create a class for the config and make it easy to access.
+* [X] postgres:// url is failing.
* [X] Implement \l, show databases
* [X] DESCRIBE is also not listed in the autocompletion.
* [X] Add MySQL commands (use, describe etc)
diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py
index 2d276e8d..1edbf079 100644
--- a/pgcli/pgexecute.py
+++ b/pgcli/pgexecute.py
@@ -49,11 +49,12 @@ class PGExecute(object):
databases_query = '''SELECT datname FROM pg_database;'''
def __init__(self, database, user, password, host, port):
- self.conn = psycopg2.connect(database)
(self.dbname, self.user, self.password, self.host, self.port) = \
_parse_dsn(database, default_user=user,
default_password=password, default_host=host,
default_port=port)
+ self.conn = psycopg2.connect(database=self.dbname, user=self.user,
+ password=self.password, host=self.host, port=self.port)
self.conn.autocommit = True
def run(self, sql):
@@ -114,11 +115,3 @@ class PGExecute(object):
with self.conn.cursor() as cur:
cur.execute(self.databases_query)
return [x[0] for x in cur.fetchall()]
-
- #def _meta_execute(self, sql, query_params=()):
- #with self.conn.cursor() as cur:
- #if query_params:
- #cur.execute(sql, query_params)
- #else:
- #cur.execute(sql)
- #return [x[0] for x in cur.fetchall()]