Skip to content

Commit

Permalink
Log DB close time, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed May 16, 2016
1 parent bba7318 commit 5b35bea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Db/Db.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def connect(self):
self.log.debug("Db file not exist yet: %s" % self.db_path)
self.conn = sqlite3.connect(self.db_path)
if config.verbose:
self.log.debug("Connected to Db in %.3fs" % (time.time()-s))
self.log.debug("Connected to Db in %.3fs" % (time.time() - s))
self.conn.row_factory = sqlite3.Row
self.conn.isolation_level = None
self.cur = self.getCursor()
Expand All @@ -67,8 +67,7 @@ def connect(self):
if self.foreign_keys:
self.execute("PRAGMA foreign_keys = ON")
if config.verbose:
self.log.debug("Db is ready to use in %.3fs" % (time.time()-s))

self.log.debug("Db is ready to use in %.3fs" % (time.time() - s))

# Execute query using dbcursor
def execute(self, query, params=None):
Expand All @@ -78,7 +77,7 @@ def execute(self, query, params=None):
return self.cur.execute(query, params)

def close(self):
self.log.debug("Closing, opened: %s" % opened_dbs)
s = time.time()
if self in opened_dbs:
opened_dbs.remove(self)
if self.cur:
Expand All @@ -87,6 +86,7 @@ def close(self):
self.conn.close()
self.conn = None
self.cur = None
self.log.debug("Closed in %.3fs, opened: %s" % (time.time() - s, opened_dbs))

# Gets a cursor object to database
# Return: Cursor class
Expand Down Expand Up @@ -318,4 +318,4 @@ def loadJson(self, file_path, file=None, cur=None):
cur.execute("COMMIT")
print "Done in %.3fs" % (time.time() - s)
for query, stats in sorted(dbjson.query_stats.items()):
print "-", query, stats
print "-", query, stats

0 comments on commit 5b35bea

Please sign in to comment.