Skip to main content

File data base system used to save/update/delete/find class objects to files easly

Project description

  • FDBM
  • File data base system used to save/update/delete/find class objects to files easly.
  • After you create your class you can do save, update, delete and find objects of that class instance without having to write code for these opertaions.

Exemple:

file test_fdb.py:

from pathlib import Path
from fdbm.model_base import FDBModel, FDBManager
from automotive_structure import Car, Engine


if __name__ == "__main__":
    
    #Set model path
    pathi = str((Path(__file__).parent).absolute())
    
    #Init model
    FDBModel.initialize(pathi)

    #Save class object
    myCar = Car('Peugeot', '504GL', 1970, 'Essence')
    myCar.saveNew()
    myCarObj = FDBModel.manager.find(type_of=Car, brand='Peugeot')

    #Save class object with subobject
    myEngine = Engine('Essence', 2.4, 'France')
    myCar = Car('Peugeot', '505GL', 1980, myEngine)
    myCar.saveNew()
    myCarObjList = FDBModel.manager.find(type_of=Car, brand='Peugeot')

    #Save class object with sub object with path arguemnt

    myEngine = Engine('Essence', 1.8, 'France')
    myCar = Car('Peugeot', '504GL', 1970, myEngine)
    myCar.saveNew('peugeot.pgt')
    myCarObjList = FDBModel.manager.get('peugeot.pgt')
      
    #Edit class object with sub object
    myCarObjList = FDBModel.manager.find(type_of=Car, brand='Peugeot')
    myCarObjList[2].model = '305'
    #sub object modification
    myCarObjList[2].engine.size = 1.6
    myCarObjList[2].update()

    myCarObjList = FDBModel.manager.find(type_of=Car, brand='Peugeot')

    #Delete one speicifc object
    isDeleted = FDBModel.manager.delete(myCarObjList[2])

    #List will have only two element
    myCarObjList = FDBModel.manager.find(type_of=Car, brand='Peugeot')

    #Delete all objects of type Car
    isDeleted = FDBModel.manager.deleteAll(type_of=Car)

    #List will have Zero element
    myCarObjList = FDBModel.manager.find(type_of=Car, brand='Peugeot')

    print('Done!')

File automotive_structure.py

from fdbm.fdb_base import FDBase
class Car(FDBase):
    
    def __init__(self, brand, model, year, engine):
        self.brand = brand
        self.model = model
        self.year = year
        self.engine = engine

class Engine(FDBase):
    
    def __init__(self, type, size, origine):
        self.type = type
        self.size = size
        self.origine = origine

FDBM repo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fdbm-0.0.3.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file fdbm-0.0.3.tar.gz.

File metadata

  • Download URL: fdbm-0.0.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1

File hashes

Hashes for fdbm-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fc5a65d8fa8f2f8a6ae83fd8e212f735eed6d1bd2395b1dcca5079f59e8b6505
MD5 4414226e54555db5711a4efb8da8f13a
BLAKE2b-256 fc708c7be2a0e2631b439709766bd1e0d6c347d8223d1c157d14572bf945b790

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page