Package: namedb
All rights are reserved to Name.dataget a datacheck if a data existget (select)parameters : valueName(str), Category(optional(str))if value is None value will return Noneimportnamedbprint(f'Price :{namedb.get("price")}')error handlingexemple :importnamedbtry:namedb.get('a world without taxes')exceptnamedb.ValueNotExist:print('Damn it')Mutli-tasking select more then one thing using || to separate themreturn a list of all of the arugments instanid of just the argumentexemple :importnamedbthing=namedb.get('a life|| a world without taxes')print(thing[0])print(thing[1])search (exist)parameters : valueName(str), Category(optional(str))if value exist it will return True (bool)else Falseimportnamedbvar=namedb.search('price')ifvar:print('Give me your money!')mutli-tasking separate differents ellement with ||return True is all the values exist else it return Falseimportnamedbvar=namedb.search('price||due')ifvar:print('Give me your money!')edit-dataadd (aadd)parameters : ValueName(str), Value(Any), Category(optional(str))if worked it will return True else Falseimportnamedbnamedb.add('price',90)error handlingexemple :importnamedbtry:namedb.add('taxes',0.19)exceptnamedb.ValueAlreadyExist:print('Damn it')edit (replace)Big updates with editedit-valueparameters : valuename(str), value(any)importnamedbnamedb.edit('taxes','does not exist')add to a numberparameters : valuename(str), add(int)importnamedbnamedb.edit('tomatostock',add=3)minus to a numberparameters : valuename(str), minus(int)importnamedbnamedb.edit('tomatostock',minus=5)append to a listparameters : valuename(str), append(any)importnamedbnamedb.edit('product',append='tomato')remove to a listparameters : valuename(str), remove(any)importnamedbnamedb.edit('product',remove='tomato')remove (delete)parameters : ValueName(str), cache(optional(bool)), Category(optional(str))if worked it will return True else Falsestock the value in the cache if cache is true (false by default)importnamedbnamedb.remove('price')error handlingexemple :importnamedbtry:namedb.remove('a world without taxes')exceptnamedb.ValueNotExist:print('Damn it')mutli-tasking separate the values that you want to delete with ||importnamedbnamedb.remove('price||due')jsonjust transfer json for nowtransferjson (atransferjson)parameters : Data(json), Category(optional(str))if worked it will return True else Falseimportnamedbjsoncode={'price':90,'due':60}namedb.transferjson(jsoncode)print(f'{namedb.get("price")}')prefixfind or edit data with a prefixprefix (aprefix)parameters : type(value or name), prefix(str), Category(optional(str))return a list with all the files that starts with the prefiximportnamedbforcostumerinnamedb.prefix(type='value','costumersdue'):print(f'Due :{costumer}')error handlingexemple :importnamedbtry:namedb.prefix('hi','taxes')exceptValueError:print('Damn it')clearprefix (cleanprefix)parameters : prefix(str), Category(optional(str))delete all the values that starts with the prefiximportnamedbnamedb.clearprefix('due')cacheRestore data or remove data with a prefix or withoutrestore (arestore)parameters : valuename(str), Category(optional(str))restore a value from the cache (and return it)importnamedbnamedb.remove('taxes')print('too good to be real')namedb.restore('taxes')error handlingexemple :importnamedbtry:namedb.restore('a world without taxes')exceptnamedb.ValueNotExist:print('Damn it')clearcache (cleancache)parameters : None
clear the cacheimportnamedbnamedb.remove('money')namedb.clearcache()clearcacheprefix (cleancacheprefix)parameters : prefix(str), Category(optional(str))
clear the cache with a prefiximportnamedbnamedb.remove('exemple2286')namedb.clearcacheprefix('exemple')categorycreate a category or remove itWe highly recommend using categorycreatecat (acreatecat)Parameters : categoryname(str)Create a categoryimportnamedbnamedb.createcat('example')deletecat (adeletecat)Parameters : categoryname(str)Delete a categoryimportnamedbnamedb.deletecat('example')listcat (alistcat)parameters : catname(str), type(str ["name", "value"])list all values or nameimportnamedbforvalueinnamedb.listcat('stock','name'):print(value)asynceverything work the same just change the name of the fonction
example :importnamedbasyncdefget_money(user_id:str):value=awaitnamedb.select(f'money{user_id}')returnvaluesetupinstall setup.py and run it (answers the questions)Directorypath(example:C:/windows/desktop/my/project/):C:/windows/Users/Me/Pycharm/project/migrating from version 1.6multi-tasking now existexample:importnamedbnamedb.remove('taxes||bad things')recommandationPlease use try: and except: if you run a constant code because this errors can make your code stopWe higly recommend using categoryWe aren't responsible for data lost.bonusThis is one of the last versions of this database because I havte no ideas of what to do now except optimisation so don't expect big changes for the next versions it's probably be like backend optimisationsI will check to publish this as python package btw