PastepDB is a fast json database with cool methods. It makes a seperated file for each data and it can index them quickly
- Fast
- Easily config and migration
- ✨ Magic ✨
- Embedded database
- Read method
- Get method
- Insert data
- Delete data
- Update data
- Migrate
PastepDB is used in https://pastep.com and Pastep Discord bot
PastepDB requires Python v3.6+ to run.
Install PastepDB using PIP
pip install pastepdbDependencies: (not needed to install manually, it will install automatically)
pip install betterlog- First setup Database config (it can be fount bellow
Starting a Databasesection) - Setup a folder called
database(name its changeable...) - Import
PastepDBinto your project
from pastepdb import pastepdb
pastepdb = pastepdb(database_config='database_config.json', database_folder='database')- Migrate your database for creating folders and etc... using migrate method (After delete it)
pastepdb.migerate()This is a sample
{
"users": {
"values": {
"fname": {
"type": "string",
"default": ""
},
"lname": {
"type": "string",
"default": ""
},
"number": {
"type": "int",
"default": 900
}
}
},
"posts": {
"values": {
"title": {
"type": "string",
"length": 100,
"default": "Untitled"
}
}
}
}Want to use PastepDB? Great! Here is a tutorial for methods (CRUD)
# Inserted data is sample
response = pastepdb.insert(target_database='users', data={
'fname': 'Pooria',
'lname': 'Ahmadi',
'phone_number': "0903333333"
})
print(response) # Will return True if its successfull# Filtered data is sample
response = pastepdb.read(database='users', values={
'fname': 'Pooira'
})
print(response) # Will return a LIST of founded data's
for item in response:
print(response)# Recived data is sample
response = pastepdb.get(database='users', where={
'fname': 'Pooira'
})
print(response) # Will return a DICT object with data # Recived list is sample
response = pastepdb.all(database='users')
print(response) # Will return a list object with data # Updated data is sample
response = pastepdb.update(database='users', where={
'id': 3
}, new_values={
"fname": "The man who is a man"
})
print(response) # Will return True if operation is successful# Updated data is sample
response = pastepdb.update(database='users', where={
"params": {
"fname": "Pooria"
}
}, new_values={
"fname": "The man who is a man"
})
print(response) # Will return True if operation is successful# Deleted data is sample
response = pastepdb.delete(database='users', where={
'id': 3
})
print(response) # Will return True if operation is successful# Deleted data is sample
response = pastepdb.delete(database='users', where={
"params": {
"fname": "Pooria"
}
})
print(response) # Will return True if operation is successfulGood documentation, isn't it? :)
MIT