code: def main(master_dsn, slave_dsn, tables, blocking=False):
      
      # currently only supports mysql master
      assert master_dsn.startswith("mysql")
  
      logger = logging.getLogger(__name__)
      logger.info("replicating tables: %s" % ", ".join(tables))
  
      repl_db_sub(master_dsn, slave_dsn, tables)
      mysql_pub(master_dsn, blocking=blocking)
docs: DB Replication app.
  
      This script will replicate data from mysql master to other databases(
      including mysql, postgres, sqlite).
  
      This script only support a very limited replication:
      1. data only. The script only replicates data, so you have to make sure
      the  tables already exists in slave db.
      2. pk only. The script replicate data by pk, when a row_pk changed, it
      retrieve it from master and write in to slave.
  
      :param master_dsn: mysql dsn with row-based binlog enabled.
      :param slave_dsn: slave dsn, most databases supported including mysql,
      postgres, sqlite etc.
      :param tables: the tables need to be replicated
      :param blocking: by default, the script only reads existing binlog,
      replicate them and exit. if  set to True,  this script will run as a
      daemon and wait for more mysql binlog and do replicates.