def __init__(self, db, subscription, ds, address, timestamp_range=None, port=None, page_size=50):
        self.db = db
        self.sub = subscription
        self.table_nodes = "s{acct}_Nodes".format(acct=self.sub)
        self.table_links = "s{acct}_ds{id}_Links".format(acct=self.sub, id=ds)
        self.table_links_in = "s{acct}_ds{id}_LinksIn".format(acct=self.sub, id=ds)
        self.table_links_out = "s{acct}_ds{id}_LinksOut".format(acct=self.sub, id=ds)

        self.ds = ds
        self.ip_start, self.ip_end = sam.common.determine_range_string(address)
        self.page_size = page_size
        self.port = port
        if timestamp_range:
            self.time_range = timestamp_range
        else:
            linksModel = sam.models.links.Links(db, self.sub, self.ds)
            tr = linksModel.get_timerange()
            self.time_range = (tr['min'], tr['max'])

        if self.db.dbname == 'mysql':
            self.elapsed = '(UNIX_TIMESTAMP(MAX(timestamp)) - UNIX_TIMESTAMP(MIN(timestamp)))'
            self.divop = 'DIV'
        else:
            self.elapsed = '(MAX(timestamp) - MIN(timestamp))'
            self.divop = '/'
            sam.common.sqlite_udf(self.db)