![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
git clone https://github.com/terribleMOTHMAN/JsthonDb
cd JsthonDb
python setup.py install
uuid
>= 1.30ujson
>= 5.6.0
{
"tvshows": {
"keys": [
],
"data": {
}
},
"films": {
"keys": [
],
"data": {
}
}
}
from jsthon import JsthonDb
db = JsthonDb('main.json')
We created that empty file
{
}
Example usage (name field must be str)
db.create_table('tvshows')
db.create_table('films')
{
"tvshows": {
"keys": [
],
"data": {
}
},
"films": {
"keys": [
],
"data": {
}
}
}
You need to know that after using this method table that will be changed by the default methods will be films. Because it was created last
Example usage (table field must be str)
db.choose_table('tvshows')
All the methods we will use will change the table 'tvshows' because we have chosen it
Example usage (data field must be dict)
id = db.add({'name': 'Breaking Bad', 'start': 2008})
print(id)
Output
279161855443486914901758992112454064004
Also we can use our own id without generating it (id field must be string)
id = db.add({'name': 'Mr. Robot', 'start': 2015}, "1")
print(id)
Output
1
Example usage (data field must be list with elements that are dictionaries)
added_values = db.add_many([{'name': 'Shameless', 'start': 2011}, {'name': 'The Boys', 'start': 2019}])
print(added_values)
Output
{'227987855254015167042504673548582084559': {'name': 'Shameless', 'start': 2011}, '334561175396969661937858438600623257934': {'name': 'The Boys', 'start': 2019}}
Also we can use our own ids without generating it (id field must be tuple with ids that are strings). Also, each id must correspond to a value in the data field
added_values = db.add_many([{'name': 'Scrubs', 'start': 2001}, {'name': 'How I Met Your Mother', 'start': 2005}], ("0", "2"))
print(added_values)
Output
{'0': {'name': 'Scrubs', 'start': 2001}, '2': {'name': 'How I Met Your Mother', 'start': 2005}}
Example usage
all = db.take_all()
print(all)
Output
{'279161855443486914901758992112454064004': {'name': 'Breaking Bad', 'start': 2008}, '1': {'name': 'Mr. Robot', 'start': 2015}, '227987855254015167042504673548582084559': {'name': 'Shameless', 'start': 2011}, '334561175396969661937858438600623257934': {'name': 'The Boys', 'start': 2019}, '0': {'name': 'Scrubs', 'start': 2001}, '2': {'name': 'How I Met Your Mother', 'start': 2005}}
Example usage
element = db.take_by_id("1")
print(element)
Output
{'name': 'Mr. Robot', 'start': 2015}
Example usage
def func(data):
if data['start'] > 2010:
return True
print(db.take_with_function(func))
Output
{'1': {'name': 'Mr. Robot', 'start': 2015}, '227987855254015167042504673548582084559': {'name': 'Shameless', 'start': 2011}, '334561175396969661937858438600623257934': {'name': 'The Boys', 'start': 2019}}
Example usage
updated_data = db.update_by_id("1", {'name': 'Better Call Saul'})
print(updated_data)
print(db.take_by_id("1"))
Output
{'name': 'Better Call Saul', 'start': 2015}
{'name': 'Better Call Saul', 'start': 2015}
Example usage
def func(data):
if data['name'] == 'Shameless':
return True
updated_data = db.update_with_function(func, {'name': '$hameless'})
print(updated_data)
Output
['227987855254015167042504673548582084559']
Example usage
deleted_data = db.delete_by_id("227987855254015167042504673548582084559")
print(deleted_data)
Output
{'name': '$hameless', 'start': 2011}
Example usage
def func(data):
if data['start'] < 2015:
return True
deleted_data = db.delete_with_function(func)
print(deleted_data)
Output
[{'name': 'Scrubs', 'start': 2001}, {'name': 'How I Met Your Mother', 'start': 2005}, {'name': 'Breaking Bad', 'start': 2008}]
Example usage
db.add_new_key('broadcast', True)
print(db.take_all())
Output
{'1': {'name': 'Better Call Saul', 'start': 2015, 'broadcast': True}, '334561175396969661937858438600623257934': {'name': 'The Boys', 'start': 2019, 'broadcast': True}}
Example usage
db.add_new_keys(['ratings', 'language'], ['good', 'english'])
print(db.take_all())
Output
{'1': {'name': 'Better Call Saul', 'start': 2015, 'broadcast': True, 'ratings': 'good', 'language': 'english'}, '334561175396969661937858438600623257934': {'name': 'The Boys', 'start': 2019, 'broadcast': True, 'ratings': 'good', 'language': 'english'}}
Example usage
a = db.show_table()
print(a)
Output
[['name', 'start', 'broadcast', 'ratings', 'language'], ['Better Call Saul', 2015, True, 'good', 'english'], ['The Boys', 2019, True, 'good', 'english']]
Example usage
db.clear_table()
Json file
{
"tvshows": {
"keys": [
],
"data": {
}
},
"films": {
"keys": [
],
"data": {
}
}
}
Example usage
db.clear_db()
Json file
{
}
It's raised when key was unrecognised or missed
It's raised when function was given to the method is not callable or is not function
It's raised when idswas given to the method have wrong type
It's raised when id was not found in the table
It's raised when id was given to the methon is not unique in the table
It's raised when name of table that was given is not unique
It's raised when wrong filename was given to a class
I need your review! It will be pleasure for me ^_^
FAQs
Easy to use, fast, productive json database for python
We found that jsthon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.