def populate_tables(db, prefix, tmp_prefix, bounds):
 bbox = ('ST_SetSRID(ST_MakeBox2D(ST_MakePoint(%.6f, %.6f), ST_MakePoint(%.6f, %.6f)), 900913)' % bounds)
 db.execute('BEGIN')
 for table in ('point', 'line', 'roads', 'polygon'):
  db.execute(('DELETE FROM %(prefix)s_%(table)s WHERE ST_Intersects(way, %(bbox)s)' % locals()))
  db.execute(('INSERT INTO %(prefix)s_%(table)s\n                      SELECT * FROM %(tmp_prefix)s_%(table)s\n                      WHERE ST_Intersects(way, %(bbox)s)' % locals()))
 db.execute('COMMIT')

def populate_tables ( db , prefix , tmp_prefix , bounds ) : bbox = ( 'ST_SetSRID(ST_MakeBox2D(ST_MakePoint(%.6f, %.6f), ST_MakePoint(%.6f, %.6f)), 900913)' % bounds ) db . execute ( 'BEGIN' ) for table in ( 'point' , 'line' , 'roads' , 'polygon' ) : db . execute ( ( 'DELETE FROM %(prefix)s_%(table)s WHERE ST_Intersects(way, %(bbox)s)' % locals ( ) ) ) db . execute ( ( 'INSERT INTO %(prefix)s_%(table)s\n                      SELECT * FROM %(tmp_prefix)s_%(table)s\n                      WHERE ST_Intersects(way, %(bbox)s)' % locals ( ) ) ) db . execute ( 'COMMIT' )
move prepared osm data from temporary to permanent tables .