#NEWLINE# def initialize_database( ) : #NEWLINE# #INDENT# world = World . get_world ( ) #NEWLINE# world . db . conn . cursor ( ) . execute ( 'PRAGMA foreign_keys = true' ) #NEWLINE# db_table_names = [ x [ 'name' ] for x in world . db . select ( "name from sqlite_master where type='table'" ) ] #NEWLINE# for table_name in db_table_names : #NEWLINE# #INDENT# columns = world . db . select ( ( '* from %s limit 1' % table_name ) ) #NEWLINE# if ( columns and len ( columns ) ) : #NEWLINE# #INDENT# EXISTING_TABLES [ world ] = columns [ 0 ] . keys ( ) #NEWLINE# #UNINDENT# #UNINDENT# for mod in model_list . values ( ) : #NEWLINE# #INDENT# if ( mod . db_table_name not in EXISTING_TABLES ) : #NEWLINE# #INDENT# create_table ( mod ) #NEWLINE# #UNINDENT# #UNINDENT# for mod in model_list . values ( ) : #NEWLINE# #INDENT# for col in mod . db_columns : #NEWLINE# #INDENT# if ( col . name not in EXISTING_TABLES [ mod . db_table_name ] ) : #NEWLINE# #INDENT# add_column ( mod , col . name )