- for table in ('gb_postcode', 'us_postcode', 'us_state', 'us_statecounty'):
- cur.execute('TRUNCATE TABLE %s' % (table,))
+ for table in ('gb_postcode', 'us_postcode'):
+ cur.execute("select * from pg_tables where tablename = '%s'" % (table, ))
+ if cur.rowcount > 0:
+ cur.execute('TRUNCATE TABLE %s' % (table,))