Python - How To Print Sqlite Table
Here I have some simple python code to query a sqlite3 database. import sqlite3 as lite conn = lite.connect('db/posts.db') cur = conn.cursor() def get_posts(): cur.execute('S
Solution 1:
Use a context manager, so you don´t have to commit!
def get_posts():
with conn:
cur.execute("SELECT * FROM Posts")
print(cur.fetchall())
Solution 2:
Turns out I just forgot to use conn.commit()
. Hope this helps someone.
Post a Comment for "Python - How To Print Sqlite Table"