Skip to content

Commit

Permalink
sqlite storage: made max timestamp value signed 8-bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-bjareholt committed May 14, 2018
1 parent b277ed0 commit 6393abf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions aw_datastore/storages/sqlite.py
Expand Up @@ -2,7 +2,6 @@
from datetime import datetime, timezone
import json
import os
import sys
import logging

import sqlite3
Expand All @@ -16,6 +15,9 @@

LATEST_VERSION=1

# The max integer value in SQLite is signed 8 Bytes / 64 bits
MAX_TIMESTAMP = 2**63-1

CREATE_BUCKETS_TABLE = """
CREATE TABLE IF NOT EXISTS buckets (
id TEXT PRIMARY KEY,
Expand Down Expand Up @@ -174,7 +176,7 @@ def get_events(self, bucket_id: str, limit: int,
if limit <= 0:
limit = -1
starttime_i = starttime.timestamp()*1000000 if starttime else 0
endtime_i = endtime.timestamp()*1000000 if endtime else sys.maxsize
endtime_i = endtime.timestamp()*1000000 if endtime else MAX_TIMESTAMP
query = "SELECT id, starttime, endtime, datastr " + \
"FROM events " + \
"WHERE bucket = ? AND starttime >= ? AND endtime <= ? " + \
Expand All @@ -195,7 +197,7 @@ def get_eventcount(self, bucket_id: str,
self.commit()
c = self.conn.cursor()
starttime_i = starttime.timestamp()*1000000 if starttime else 0
endtime_i = endtime.timestamp()*1000000 if endtime else sys.maxsize
endtime_i = endtime.timestamp()*1000000 if endtime else MAX_TIMESTAMP
query = "SELECT count(*) " + \
"FROM events " + \
"WHERE bucket = ? AND endtime >= ? AND starttime <= ?"
Expand Down

0 comments on commit 6393abf

Please sign in to comment.