fork download
  1. #!/usr/bin/env python
  2. import sqlite3
  3.  
  4. db = sqlite3.connect(':memory:')
  5.  
  6. # create table with 2 columns
  7. db.execute('create table if not exists "table" (column_1, column_2)')
  8.  
  9. with db: # populate it
  10. db.executemany('insert into "table" values(?, ?)',
  11. [("do's", 'and'), ("don'ts", 2)])
  12.  
  13. print(*db.iterdump(), sep='\n')
  14.  
  15. with db: # delete all records from the table
  16. db.execute('delete from "table"')
  17.  
  18. print('-'*60)
  19. print(*db.iterdump(), sep='\n')
  20.  
Success #stdin #stdout 0.02s 11392KB
stdin
Standard input is empty
stdout
BEGIN TRANSACTION;
CREATE TABLE "table" (column_1, column_2);
INSERT INTO "table" VALUES('do''s','and');
INSERT INTO "table" VALUES('don''ts',2);
COMMIT;
------------------------------------------------------------
BEGIN TRANSACTION;
CREATE TABLE "table" (column_1, column_2);
COMMIT;