bee.active_record
BaseMode for active record type.
eg:
class Orders(BaseMode):
#__tablename__ = "orders"
id:int = None
name:str = None
remark:str = None
def __repr__(self):
return str(self.__dict__)
if __name__ == '__main__':
orders = Orders()
orderList=orders.select()
According to entity object update record(update record by id).This method just has id field to SQL where expression.
table's entity(do not allow null). id is where condition,do not allow null.
The entity corresponding to table and can not be null.
The ID field of entity cannot be null and as filter condition.
The not null and not empty field will update to database except ID.
Returns
the numbers of update records successfully, if fails,return integer less than 0.
According to entity object insert record.
The entity corresponding to table and can not be null.
The not null and not empty field will insert to database.
Returns
the numbers of insert records successfully, if fails,return integer less than 0.
Select the records according to entity and condition.
since 1.6.0
Parameters
- condition: If the field of entity is not null or empty, it will be translate to field=value.
Other can define with condition.
Returns
list which contains more than one entity.
Delete the records according to entity and condition.
since 1.6.0
Parameters
- condition: If the field of entity is not null or empty, it will be translate to field=value.Other can define with condition.
Returns
the number of deleted record(s) successfully, if fails,return integer less than 0.
Just select some fields,and can specify page information.
Parameters
- start: start index,min value is 0 or 1(eg: MySQL is 0,Oracle is 1).
- size: fetch result size (>0).
- selectFields: select fields, if more than one,separate with comma in one selectField parameter or use variable parameter.
Returns
list which contains more than one entity.
Select record by id.
Parameters
- id: value of entity's id field.
Returns
return one entity which owns this id.
Delete record by id.
Parameters
- ids: value of entity's id field.
Returns
the number of deleted record(s) successfully,if fails, return integer less than 0.
Select result with one function,Just select one function.
Parameters
- functionType: MAX,MIN,SUM,AVG,COUNT
- field_for_fun: field for function.
Returns
one function result.
If the result set of statistics is empty,the count return 0,the other return empty string.
total number of statistical records.
Returns
total number of records that satisfy the condition.
Check whether the entity corresponding record exist
Returns
true,if have the record, or return false.
Update record according to whereFields.
Parameters
- condition: Condition as filter the record.
- whereFields: As a field list of where part in SQL, multiple fields can separated by commas in one
whereField parameter or use variable parameter (the fields in the list will be used as where filter)
But if id's value is null can not as filter.
Notice:the method op of condition also maybe converted to the where expression.
Returns
the numbers of update record(s) successfully,if fails, return integer less than 0.