Code Monkey home page Code Monkey logo

Comments (6)

abdelhai avatar abdelhai commented on August 20, 2024 1

hi @harshitsinghai77 & @navhits

your comments demonstrate why this is not such a small task:

  1. we need to model our Base backend, especially regarding consistency and support fetch queries
  2. make sure this local "Base" works across all SDKs of other languages.

the best way to test and dev with Base is to use the actual live service.

closing this for now as we don't have any immediate plans to implement it and because the community won't be able to replicate the behavior of Base reliably.

from deta-python.

boanergies avatar boanergies commented on August 20, 2024

I also think this would be an important feature to implement from a testing perspective. As it stands if someone were to use deta base it would be expected you would have to make a test project to have a test database, meaning anyone in the future who wants to run database tests has to have a deta account and internet access. It would be nice if there was a local mock of the database to test against.

from deta-python.

abdelhai avatar abdelhai commented on August 20, 2024

Thanks @luizfelipevbll and @boanergies for bringing this to our attention!
We think this feature is very useful but rarely a blocker. In a addition, it will require a bit more work to make sure it woks across our JS/TS/Browser/HTTP/etc SDKs. As such, this feature sits low on our priority list.

from deta-python.

harshitsinghai77 avatar harshitsinghai77 commented on August 20, 2024

Any updates on this? I can help if you're looking to add this feature.

from deta-python.

navhits avatar navhits commented on August 20, 2024

If it is only for Deta Base then you can write a tiny wrapper with this boolean flag local. When you set it to true, then create or access from the local JSON file. Example:

from deta import Deta
import json, os

deta = Deta("")
class DetaBase:
    def __init__(self, db_name: str, local: bool=False):
        self.db = deta.Base(db_name)
        self.local = local

    def get(self, key: str):
        if self.local:
            with open(f"local/{self.db_name}/{key}.json", "r") as f:
                return json.load(f)
        return self.db.get(key=key)

    def put(self, key: str, data: dict):
        if self.local:
            with open(f"local/{self.db_name}/{key}.json", "w") as f:
                json.dump(data, f)
        return self.db.put(key=key, data=data)

    def delete(self, key: str):
        if self.local:
            os.remove(f"local/{self.db_name}/{key}.json")
        return self.db.delete(key=key)

I quickly wrote this. So didn't get to add other methods like insert, fetch, put_many and all that. But basically, this should help you with immediate requirements.

from deta-python.

harshitsinghai77 avatar harshitsinghai77 commented on August 20, 2024

from deta-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.