[code.view]

[top] / python / PyMOTW / sqlite3 / sqlite3_createdb.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Creating an sqlite3 database.
     """
     #end_pymotw_header
     
     import os
     import sqlite3
     
     db_filename = 'todo.db'
     
     db_is_new = not os.path.exists(db_filename)
     
     conn = sqlite3.connect(db_filename)
     
     if db_is_new:
         print 'Need to create schema'
     else:
         print 'Database exists, assume schema does, too.'
     
     conn.close()
     

[top] / python / PyMOTW / sqlite3 / sqlite3_createdb.py

contact | logmethods.com