create_connection#

View page source

Create a Python sqlite3 Database Connection#

Prototype#

# connection =
def create_connection(file_name, new = False, readonly = False) :
   assert type(file_name) == str
   assert type(new)       == bool
   assert type(readonly)  == bool

file_name#

is the name of the file where the data base is stored.

new#

If new is true, a new data base is created with the specified file name. If an old version of the file exists, its contents are lost. If new if false, the existing data base corresponding to the file name is used.

readonly#

If readonly is true, the database is opened in read only mode.

connection#

The return value is an sqlite3 connection object

Close#

You must close this connection when you are done with it by executing connection.close()

One Thread#

The connection can only be used the thread that created it.