def create_tables(db, prefix, tmp_prefix):
 for table in ('point', 'line', 'roads', 'polygon'):
  db.execute('BEGIN')
  try:
   db.execute(('CREATE TABLE %(prefix)s_%(table)s ( LIKE %(tmp_prefix)s_%(table)s )' % locals()))
  except ProgrammingError as e:
   db.execute('ROLLBACK')
   if (e.pgcode != '42P07'):
    raise
  else:
   db.execute(("INSERT INTO geometry_columns\n                          (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type)\n                          SELECT f_table_catalog, f_table_schema, '%(prefix)s_%(table)s', f_geometry_column, coord_dimension, srid, type\n                          FROM geometry_columns WHERE f_table_name = '%(tmp_prefix)s_%(table)s'" % locals()))
   db.execute('COMMIT')

def create_tables ( db , prefix , tmp_prefix ) : for table in ( 'point' , 'line' , 'roads' , 'polygon' ) : db . execute ( 'BEGIN' ) try : db . execute ( ( 'CREATE TABLE %(prefix)s_%(table)s ( LIKE %(tmp_prefix)s_%(table)s )' % locals ( ) ) ) except ProgrammingError as e : db . execute ( 'ROLLBACK' ) if ( e . pgcode != '42P07' ) : raise else : db . execute ( ( "INSERT INTO geometry_columns\n                          (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type)\n                          SELECT f_table_catalog, f_table_schema, '%(prefix)s_%(table)s', f_geometry_column, coord_dimension, srid, type\n                          FROM geometry_columns WHERE f_table_name = '%(tmp_prefix)s_%(table)s'" % locals ( ) ) ) db . execute ( 'COMMIT' )
create all tables for the given model .