Skip to content

Commit

Permalink
correct order of function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
karlud committed Feb 13, 2017
1 parent 395458c commit 87da077
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion vagrant/forum/solution/forumdb_solved.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion vagrant/forum/solution/forumdb_stepone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 2 additions & 1 deletion vagrant/forum/solution/forumdb_steptwo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 87da077

Please sign in to comment.