1
0
mirror of https://github.com/dbcli/pgcli synced 2024-06-24 02:03:20 +00:00

Return the results in the form of a tuple.

This commit is contained in:
Amjith Ramanujam 2014-12-10 09:03:35 -08:00
parent e3f7d263f3
commit d292e68d31

View File

@ -29,6 +29,9 @@ class PGExecute(object):
return (command.strip(), verbose, arg.strip())
def run(self, sql):
"""Execute the sql in the database and return the results. The results
are a list of tuples. Each tuple has 3 values (rows, headers, status).
"""
# Remove spaces, eol and semi-colons.
sql = sql.strip()
@ -57,9 +60,9 @@ class PGExecute(object):
# rows.
if cur.description:
headers = [x[0] for x in cur.description]
return [cur.fetchall(), headers, cur.statusmessage]
return [(cur.fetchall(), headers, cur.statusmessage)]
else:
return [None, None, cur.statusmessage]
return [(None, None, cur.statusmessage)]
def tables(self):
with self.conn.cursor() as cur: