Comments (6)
hi @harshitsinghai77 & @navhits
your comments demonstrate why this is not such a small task:
- we need to model our Base backend, especially regarding consistency and support fetch queries
- 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.
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.
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.
Any updates on this? I can help if you're looking to add this feature.
from deta-python.
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.
from deta-python.
Related Issues (20)
- TypeError: 'FetchResponse' object is not an iterator HOT 2
- The read operation timed out HOT 1
- AttributeError: module 'orjson' has no attribute 'JSONEncoder' in /opt/python/detalib/helpers.py class CustomJSONEncoder(json.JSONEncoder): HOT 5
- Base needs remove HOT 1
- send_email function in __init__.py HOT 3
- cron job App is not defined HOT 5
- Async Base TimeoutError HOT 1
- Deta is storing the wrong int HOT 1
- Questions: Does Deta supports npm? HOT 1
- Don't raise with the Exception class HOT 2
- Keyword argument expire_at for base.put() method not found (Python) HOT 3
- Wrong information in CONTRIBUTING.md HOT 1
- Deta Command Not Found HOT 1
- ✋ Use Discussions to get help: https://github.com/orgs/deta/discussions
- Empty keys not allowed HOT 1
- Add type hints strictly and provide
- Micro erroring due to detalib HOT 4
- The update() method seems to have a problem HOT 1
- ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426) when trying to upload file to Deta drive HOT 2
- broken app HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deta-python.