Commits

Nik Cubrilovic committed 4b4cf9b

db reads from config for path

  • Participants
  • Parent commits b4d8bb4

Comments (0)

Files changed (1)

File cexbot/db.py

 import logging
 import sqlite3 as lite
 
+import config
+
 class DbManager(object):
-  DB_NAME = 'cex.db'
 
-  def __init__(self, dbname=None):
-    if not dbname:
-      dbname = self.DB_NAME
-    self.conn = lite.connect(dbname)
+  def __init__(self, path_db=None):
+    if not path_db:
+      path_db = config.get_db_path()
+    self.conn = lite.connect(path_db)
     self.conn.execute('pragma foreign_keys = on')
     self.conn.commit()
     self.cur = self.conn.cursor()
     con = lite.connect(DB_NAME)
     return con
 
-  def initdb(self):
+  def init(self):
     self.cur.execute("CREATE TABLE IF NOT EXISTS quotes (time INTEGER primary key, last integer, volume integer, high integer, low integer, bid integer, ask integer)")
-    logging.info('db initialized')
+    logging.info('Database Initialized')
     return True