Skip to content

Commit 9bfc0ec

Browse files
authored
Update 160518-install-postgresql-python-3-ubuntu-1604.markdown
Fixed Bug , which caused expection 'cursor already closed'
1 parent a9d9e80 commit 9bfc0ec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/posts/160518-install-postgresql-python-3-ubuntu-1604.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ and "password" values with your own.
164164
# run a SELECT statement - no data in there, but we can try it
165165
cursor.execute("""SELECT * from tutorials""")
166166
conn.commit() # <--- makes sure the change is shown in the database
167-
conn.close()
168-
cursor.close()
169167
rows = cursor.fetchall()
170168
print(rows)
169+
cursor.close()
170+
conn.close()
171171
except Exception as e:
172172
print("Uh oh, can't connect. Invalid dbname, user or password?")
173173
print(e)

0 commit comments

Comments
 (0)