gprs_database.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码
def get_records(self, start_timestamp=0, end_timestamp=None):
        """Gets records from the table between the specified timestamps.

        Args:
          Timestamps are given in seconds since epoch.

        Returns a list of dicts, each of the form: {
            'id': 3,
            'record_timestamp': 1341556432,
            'imsi': 'IMSI901550000000084',
            'ipaddr': '192.168.99.3',
            'uploaded_bytes': 5567,
            'downloaded_bytes': 9987,
            'uploaded_bytes_delta': 74,
            'downloaded_bytes_delta': 139
        }
        """
        start = psycopg2.TimestampFromTicks(start_timestamp)
        if not end_timestamp:
            end_timestamp = time.time()
        end = psycopg2.TimestampFromTicks(end_timestamp)
        template = ('select * from %s where record_timestamp >= %s'
                    ' and record_timestamp <= %s')
        command = template % (self.table_name, start, end)
        with self.connection.cursor(
            cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
            cursor.execute(command)
            self.connection.commit()
            return cursor.fetchall()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号