티스토리 뷰

programming/python

python sqlite3

ba0bab 2018. 8. 26. 12:35

import sqlite3


conn = sqlite3.connect("asdf.db")


cur = conn.cursor()

cur.execute("SELECT * FROM general")


rows = cur.fetchall()

for row in rows:

    print(row)


conn.close()



hyomin@ubuntu:~/flask_project$ python sql.py 

(1, u'\uc655\uac74', 89)

(2, u'\ubc15\uc220\ud76c', 97)

(3, u'\uc655\uc2dd\ub834', 84)

(4, u'\uc2e0\uc22d\uacb8', 98)

(5, u'\uad81\uc608', 77)

(6, u'\uc720\uae08\ud544', 99)

(7, u'\ub2a5\ud658', 27)

(8, u'\uc560\uc220', 91)

(9, u'\uc885\uac04', 39)

(10, u'\uc544\uc9c0\ud0dc', 15)

(11, u'\uc724\uc2e0\ub2ec', 81)

'programming > python' 카테고리의 다른 글

db 기본 문법  (0) 2018.08.31
[python sqlite3]? Placeholder / Named Placeholder  (0) 2018.08.26
[Flask] sqlite3 사용예제  (0) 2018.08.26
[Flask] url_for  (0) 2018.08.25
[Flask] debug mode  (0) 2018.08.25
Comments