Bases: flask_sqlalchemy.SQLAlchemy
Sets the Model class to ModelBooster, providing all the methods defined on ModelBooster
Examples
>>> db = FlaskSQLAlchemyBooster()
>>> class User(db.Model):
id = db.Column(db.Integer, primary_key=True, unique=True)
email = db.Column(db.String(100), unique=True)
password = db.Column(db.String(100))
name = db.Column(db.String(100))
contact_number = db.Column(db.String(20))
>>> User.all()
>>> u = User.first()
>>> u.todict()
DictizableMixin A mixin class to add todict method to objects.
Bases: object
list of str
The columns which should be serialized as a part of the output dictionary
dict of str,str
A dictionary used to map the display names of columns whose original name you want to be modified in the json
list of (str, str)
A list of tuples. The first element of the tuple is the relationship that is to be serialized. The second element it the name of the attribute in the related model, the value of which is to be used as the representation
list of str
A list of relationships to expand. You can specify nested relationships by placing dots.
dict of str, list of str
A dictionary representing how to hierarchially group a list like relationship. The relationship fields are the keys and the list of the attributes based on which they are to be grouped are the values.
Converts and instance to a dictionary with only the specified attributes as keys
Parameters: | *args – The arguments to serialize |
---|
Examples
>>> customer = Customer.create(name="James Bond", email="007@mi.com",
phone="007", city="London")
>>> customer.serialize_attrs('name', 'email')
{'name': u'James Bond', 'email': u'007@mi.com'}
Just an alias for some functions which might still use old name
Converts an instance to a dictionary form
Parameters: |
|
---|
Borrows heavily from https://github.com/mattupstate/overholt/blob/master/overholt/core.py
Bases: object
list
The list of attributes that should not be overwritten
Returns a list of instances of the service’s model filtered by the specified key word arguments.
Parameters: | **kwargs – filter parameters |
---|
Returns a new, added but unsaved instance of the service’s model class.
Parameters: | **kwargs – instance parameters |
---|
Returns a new, saved instance of the service’s model class.
Parameters: | **kwargs – instance parameters |
---|
Returns a list of instances of the model filtered by the specified key word arguments.
Parameters: | **kwargs – |
---|
Checks if an instance already exists in db with these kwargs else returns a new, saved instance of the service’s model class.
Parameters: | **kwargs – instance parameters |
---|
Checks if an instance already exists in db with these kwargs else returns a new, saved instance of the service’s model class.
Parameters: | **kwargs – instance parameters |
---|
Returns the first instance found of the service’s model filtered by the specified key word arguments.
Parameters: | **kwargs – filter parameters |
---|
Returns an instance of the service’s model with the specified id. Returns None if an instance with the specified id does not exist.
Parameters: | id – the instance id |
---|
Returns an updated instance of the service’s model class.
Parameters: |
|
---|
Returns an updated instance of the service’s model class.
Parameters: |
|
---|
Returns an instance of the service’s model with the specified id or raises an 404 error if an instance with the specified id does not exist
Parameters: | id – the instance id |
---|
Returns a new, unsaved instance of the service’s model class.
Parameters: | **kwargs – instance parameters |
---|
Saves a model instance to db
>>> customer = Customer.new(name="hari")
>>> customer.save()
Bases: flask_sqlalchemy.Model, flask_sqlalchemy_booster.queryable_mixin.QueryableMixin, flask_sqlalchemy_booster.dictizable_mixin.DictizableMixin
alias of QueryBooster