From 87da0778f00a4316e6a5a0f8ad4665f1a816fc75 Mon Sep 17 00:00:00 2001 From: Karl Krueger Date: Mon, 13 Feb 2017 13:51:16 -0800 Subject: [PATCH] correct order of function calls --- vagrant/forum/solution/forumdb_solved.py | 3 ++- vagrant/forum/solution/forumdb_stepone.py | 3 ++- vagrant/forum/solution/forumdb_steptwo.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/vagrant/forum/solution/forumdb_solved.py b/vagrant/forum/solution/forumdb_solved.py index a3f4340892..1b4479d277 100644 --- a/vagrant/forum/solution/forumdb_solved.py +++ b/vagrant/forum/solution/forumdb_solved.py @@ -9,8 +9,9 @@ def get_posts(): db = psycopg2.connect(database=DBNAME) c = db.cursor() c.execute("select content, time from posts order by time desc") - return c.fetchall() + posts = c.fetchall() db.close() + return posts def add_post(content): """Add a post to the 'database' with the current timestamp.""" diff --git a/vagrant/forum/solution/forumdb_stepone.py b/vagrant/forum/solution/forumdb_stepone.py index 8820e6c5c4..c224866d1b 100644 --- a/vagrant/forum/solution/forumdb_stepone.py +++ b/vagrant/forum/solution/forumdb_stepone.py @@ -11,8 +11,9 @@ def get_posts(): db = psycopg2.connect(database=DBNAME) c = db.cursor() c.execute("select content, time from posts order by time desc") - return c.fetchall() + posts = c.fetchall() db.close() + return posts def add_post(content): """Add a post to the 'database' with the current timestamp.""" diff --git a/vagrant/forum/solution/forumdb_steptwo.py b/vagrant/forum/solution/forumdb_steptwo.py index 64e19e3e40..59221543fa 100644 --- a/vagrant/forum/solution/forumdb_steptwo.py +++ b/vagrant/forum/solution/forumdb_steptwo.py @@ -11,8 +11,9 @@ def get_posts(): db = psycopg2.connect(database=DBNAME) c = db.cursor() c.execute("select content, time from posts order by time desc") - return c.fetchall() + posts = c.fetchall() db.close() + return posts def add_post(content): """Add a post to the 'database' with the current timestamp."""