Beispiel #1
0
    def __init__(self, file_path='db.json', keyname=None):

        self.file_path = file_path
        self.keyname = keyname

        self.update_count = 0
        self.save_after = 10

        if not os.path.exists(self.file_path):
            #new database
            self.rows = []
            if not keyname:
                raise Exception('keyname is required')

        else:
            #existing database
            data = common.read_json(self.file_path)
            self.keyname = data['keyname']
            self.rows = data['rows']
Beispiel #2
0
	def __init__(self, file_path = 'db.json', keyname=None):
		
		self.file_path = file_path
		self.keyname = keyname

		self.update_count = 0
		self.save_after = 10

		if not os.path.exists(self.file_path):
			#new database
			self.rows = []
			if not keyname:
				raise Exception('keyname is required')


		else:
			#existing database
			data = common.read_json(self.file_path)
			self.keyname = data['keyname']
			self.rows = data['rows']
Beispiel #3
0
 def read_json(self, filename):
     return common.read_json(self.join_path(filename))
Beispiel #4
0
	def read_json(self, filename):
		return common.read_json(self.join_path(filename))