■ Connection 클래스의 iterdump 메소드를 사용해 데이터베이스 덤프를 만드는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import sqlite3 connection = sqlite3.connect(":memory:") cursor = connection.cursor() cursor.execute("CREATE TABLE PHONE_BOOK (NAME TEXT, PHONE_NUMBER TEXT);") cursor.execute("INSERT INTO PHONE_BOOK VALUES ('Derick', '010-1234-5678');") cursor.execute("INSERT INTO PHONE_BOOK VALUES ('Tom' , '010-5432-7833');") cursor.execute("INSERT INTO PHONE_BOOK VALUES ('DSP' , '010-1234-9876');") for line in connection.iterdump(): print(line) """ BEGIN TRANSACTION; CREATE TABLE PHONE_BOOK (NAME TEXT, PHONE_NUMBER TEXT); INSERT INTO "PHONE_BOOK" VALUES('Derick','010-1234-5678'); INSERT INTO "PHONE_BOOK" VALUES('Tom','010-5432-7833'); INSERT INTO "PHONE_BOOK" VALUES('DSP','010-1234-9876'); COMMIT; """ |