#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. # """Illustrate the effect of autocommit mode. """ #end_pymotw_header import sqlite3 import sys import threading import time db_filename = 'todo.db' isolation_level = None # autocommit mode def reader(conn): my_name = threading.currentThread().name print 'Starting thread' try: cursor = conn.cursor() cursor.execute('select * from task') results = cursor.fetchall() print 'results fetched' except Exception, err: print 'ERROR:', err return if __name__ == '__main__': with sqlite3.connect(db_filename, isolation_level=isolation_level) as conn: t = threading.Thread(name='Reader 1', target=reader, args=(conn,)) t.start() t.join()