Skip to content

Commit b0402e3

Browse files
authored
Merge pull request mattmakai#204 from josephpaulmckenzie/master
Added conn.commit() to actually save the table in the db
2 parents 3cb603b + 980b577 commit b0402e3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ and "password" values with your own.
163163
cursor.execute("""CREATE TABLE tutorials (name char(40));""")
164164
# run a SELECT statement - no data in there, but we can try it
165165
cursor.execute("""SELECT * from tutorials""")
166+
conn.commit() # <--- makes sure the change is shown in the database
167+
conn.close()
168+
cursor.close()
166169
rows = cursor.fetchall()
167170
print(rows)
168171
except Exception as e:

0 commit comments

Comments
 (0)