Answers for "building a database with python"

0

building a database with python

import json
import os
Posted by: Guest on November-30-2020
-1

building a database with python

class FoobarDB(object):
    def __init__(self , location):
        self.location = os.path.expanduser(location)
        self.load(self.location)

    def load(self , location):
        if os.path.exists(location):
            self._load()
        else:
            self.db = {}
        return True

    def _load(self):
        self.db = json.load(open(self.location , "r"))

    def dumpdb(self):
        try:
            json.dump(self.db , open(self.location, "w+"))
            return True
        except:
            return False
Posted by: Guest on November-30-2020

Code answers related to "building a database with python"

Python Answers by Framework

Browse Popular Code Answers by Language