check table exists and add write_data() to db