import sqlite3
conn = sqlite3.connect('db1.sqlite')
c = conn.cursor
conn.execute("SELECT * FROM users ")
with conn:
with open('..db1_dump.sql','w') as f :
for line in conn.iterdump():
f.write('%s\n' %line)
db1_dump.sql ์ด๋ผ๋ ํ์ผ์ด ์์ฑ๋๋ค.
BEGIN TRANSACTION;
CREATE TABLE users(id INTEGER PRIMARY KEY, username TEXT, email TEXT, phone TEXT, regist_date TEXT);
INSERT INTO "users" VALUES(2,'park','Park@naver,com','010-2224-2412','2020-02-23 16:55:17.658330');
INSERT INTO "users" VALUES(5,'Kim','kim@naver.com','010-2512-1212','2020-02-23 16:51:28.214145');
INSERT INTO "users" VALUES(13,'Lee','Lee@naver.com','010-2222-2222','2020-02-23 17:02:10.602053');
INSERT INTO "users" VALUES(23,'Lee','Lee@naver.com','010-2222-2222','2020-02-23 17:02:10.602053');
INSERT INTO "users" VALUES(33,'Lee','Lee@naver.com','010-2222-2222','2020-02-23 17:02:10.602053');
COMMIT;