coding

sqlite3 사용하기

유로파물고기 2021. 7. 27. 19:36
반응형
# 버전확인
import sqlite3

print(sqlite3.version) # 모듈 자체 버전
print(sqlite3.sqlite_version) # sqlite 버전

# database 생성
dbConn = sqlite3.connec(database='path')

# cursor 생성 / execute
cs = dbConn.cursor()
cs.execute("create table x(a int)")
cs.execute("insert into x values (?)", (12345,))
cs.execute("select * from x").fetchall()

# commit
dbConn.commit()

# db 닫기
dbConn.close()

'coding' 카테고리의 다른 글

생활코딩 React ~컴포넌트 만들기까지  (0) 2023.05.30
버전간의 차이점 비교~ 수업을 마치며  (0) 2022.08.03
APPLICATION / WINDOW  (0) 2021.05.14
GUI tkinter Label, Button  (0) 2021.05.13
Kotlin 기초정리2  (0) 2021.04.03