title: generalised insert into sqlalchemy using dictionary
body: <p>I'm building an application in Flask and I have several SQLAlchemy models defined. I have a dictionary with key/value pairs for each of the model types.</p>
  
  <p>I want a generalised insert using a dictionary... would this require a mapper?  I know that wtforms.ext.sqlalchemy.orm.model_form() generates an object with populate_obj(model) so it is possible.  I've combed through the documentation but can't find it.  I can perform the commit later, but need a shortcut to populate the object for now.  Please, does anyone have expertise?</p>
  
  <pre><code>from flask import Flask
  from flask.ext.sqlalchemy import SQLAlchemy
  
  app = Flask(__name__)
  db = SQLAlchemy()
  db.init_app(app)
  
  employee_data = {'firstname':'John','lastname':'Smith'}
  project_data = {'name':'project1'}
  
  dict_generalised_insert(model=Employee,dictionary=employee_data)
  dict_generalised_insert(model=Project,dictionary=project_data)
  
  def dict_generalised_insert(model=None,dictionary={})
      obj = model.model() 
      obj.populate_obj(dictionary) # ???
      return obj
  
  class Employee(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      firstname = db.Column(db.String(80))
      lastname = db.Column(db.String(80))
  
  class Project(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(80))
  </code></pre>