0 purchases
valleorm 1.0.0.3
python-ormsqlite================I've done it to work with kivy and android. It works great with mobiledevices. For people who do not seek much complexity. It is simple butyou can perform more or less complex queries. Create a model quickly inseconds. Just create the model and you can create JSON queries.:package: Installation----------------------Install it via ``pip````[sudo]pipinstallvalleorm‘‘Ordownloadzipandtheninstallitbyrunning‘‘ [sudo] python setup.py install``For kivy project only copy folder valleorm on root folder kivy project.And create your models simply.Condition example-----------------.. code:: javascript conditionQuery = { query: "nombre='Lolo'", order: "ID DESC", limt: 10, offset: 20, colunms: ["user.nombre, SUM(salario.salario) AS total"], group: "salario.mes" joins: [ { typeJoin: "INNER LEFT", tableName: "salario", join: "ID=IDuser" }, { tableName: 'puesto', //for default is INNER JOIN join: 'ID=IDuser' } ] }.. code:: python some_model = Models() rows = model.getAll(condition=conditionQuery) print Models.serialize(rows)Example from Class inheritance Models-------------------------------------.. code:: python from valleorm.models import Models from valleorm.campos import Campo from valleorm.relationship import RelationShip class User(Models): nombre = Campo(default="", tipo="TEXT") mail = Campo(default="", tipo="TEXT") salario = RelationShip(tipo="MANY", name="salario") def __init__(self): super(User, self).__init__(tableName="user", dbName="valleorm.db" ) class Salario(Models): mes = Campo(default="", tipo="TEXT") salario = Campo(default=0.0, tipo="REAL") user = RelationShip(tipo="ONE", name="user") def __init__(self): super(Salario, self).__init__(tableName="salario", dbName="valleorm.db" ) user = User() user.nombre = "manolo cara bolo" user.mail = "[email protected]" user.save() sal = Salario() sal.mes = "Mayo" sal.salario = 1500 user.salario.add(sal) sal = Salario() sal.mes = "Junio" sal.salario = 1500 user.salario.add(sal) sal = Salario() sal.mes = "Julio" sal.salario = 1500 user.salario.add(sal) sal = Salario() sal.mes = "Agosto" sal.salario = 1500 user.salario.add(sal) #load data user by ID user.loadByPk(1) print user.toJSON() row = user.salario.get() print Models.serialize(row)Example from models JSON------------------------.. code:: python from valleorm.models import Models modelUser = { #Required structure for each relationship 'relationTipo, relationName' 'relationship': [{ 'relationTipo': "MANY", # ACCEPT ONLY ONE | MANY | MANYTOMANY 'relationName': "salario", # Table name }], #Required structure for each field 'feildName, fieldTipo, fieldDato' 'fields':[ { 'fieldName': 'nombre', 'fieldTipo': 'TEXT', #ACCEPT ONLY TEXT | REAL | INTEGER 'fieldDato': "", # Value for default }, { 'fieldName': 'mail', 'fieldTipo': 'TEXT', #ACCEPT ONLY TEXT | REAL | INTEGER 'fieldDato': "", }, { 'fieldName': 'apellido', 'fieldTipo': 'TEXT', #ACCEPT ONLY TEXT | REAL | INTEGER 'fieldDato': "", } ]} modelSalario = { #Required structure for each relationship 'relationTipo, relationName, fieldDato' 'relationship':[{ 'relationTipo': "ONE", # ACCEPT ONLY ONE | MANY | MANYTOMANY 'relationName': "user", # Table name }], #Required structure for each field 'feildName, fieldTipo, fieldDato' 'fields':[ { 'fieldName': 'mes', 'fieldTipo': 'TEXT', #ACCEPT ONLY TEXT | REAL | INTEGER 'fieldDato': "", # Value for default }, { 'fieldName': 'salario', 'fieldTipo': 'REAL', #ACCEPT ONLY TEXT | REAL | INTEGER 'fieldDato': 0.0, } ] } user = Models(tableName= "user", dbName="valleorm.db", model=modelUser) sal = Models(tableName= "salario", dbName="valleorm.db", model=modelSalario) user.mail = "[email protected]" user.nombre = "El loco pitres" user.apellido = "Fuertes" user.save() sal.mes = "may" sal.salario = "1400" user.salario.add(sal) sal = Models(tableName= "salario", dbName="valleorm.db", model=modelSalario) sal.mes = "jun" sal.salario = "1400" user.salario.add(sal) sal = Models(tableName= "salario", dbName="valleorm.db", model=modelSalario) sal.mes = "jul" sal.salario = "1400" user.salario.add(sal) sal = Models(tableName= "salario", dbName="valleorm.db", model=modelSalario) sal.mes = "ago" sal.salario = "1400" user.salario.add(sal) #load data user by ID user.loadByPk(1) print user.toJSON() row = user.salario.get() print Models.serialize(row):yum: How to contribute-----------------------Have an idea? Found a bug? `add a newissue <https://github.com/vallemrv/orm-python-sqlite/issues>`__ or[fork](https://github.com/vallemrv/orm-python-sqlite#fork-destination-box) andsendme a pull request. Don't forget to add your name to the Contributorssection of this document.:scroll: License----------------Licensed under the Apache-2.0, see ``LICENSE``:heart\_eyes: Contributors--------------------------Manuel Rodriguez [email protected]
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.