def atlasdb_remove_peer( peer_hostport, con=None, path=None, peer_table=None ):
    """
    Remove a peer from the peer db and (if given) peer table.
    """
    # remove from db
    with AtlasDBOpen(con=con, path=path) as dbcon:

        log.debug("Delete peer '%s'" % peer_hostport)

        sql = "DELETE FROM peers WHERE peer_hostport = ?;"
        args = (peer_hostport,)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )
        dbcon.commit()

    # remove from the peer table as well
    with AtlasPeerTableLocked(peer_table) as ptbl:

        if ptbl.has_key(peer_hostport):
            if not atlas_peer_is_whitelisted( peer_hostport, peer_table=ptbl ) and not atlas_peer_is_blacklisted( peer_hostport, peer_table=ptbl ):
                del ptbl[peer_hostport]

    return True
Remove a peer from the peer db and (if given) peer table.