title: how to build a many-to-many relationship using the SQL Expression language
body: <p>On <a href="https://stackoverflow.com/questions/11769366/why-is-sqlalchemy-insert-with-sqlite-25-times-slower-than-using-sqlite3-directly">advice</a> from the creator of Sqlalchemy I'm attempting to write my initial bulk insert of data using the  <a href="http://docs.sqlalchemy.org/ru/latest/core/tutorial.html" rel="nofollow noreferrer">SQL Expression Language</a>. See for details.</p>
  
  <p>The tutorial covers a what i assume to be an example of a one-to-many relationship between User and Address. They create the relationship by with the use of the executemany() method: </p>
  
  <pre><code>&gt;&gt;&gt; conn.execute(addresses.insert(), [ 
  ...    {'user_id': 1, 'email_address' : 'jack@yahoo.com'},
  ...    {'user_id': 1, 'email_address' : 'jack@msn.com'},
  ...    {'user_id': 2, 'email_address' : 'www@www.org'},
  ...    {'user_id': 2, 'email_address' : 'wendy@aol.com'},
  ... ])
  INSERT INTO addresses (user_id, email_address) VALUES (?, ?)
  ((1, 'jack@yahoo.com'), (1, 'jack@msn.com'), (2, 'www@www.org'), (2, 'wendy@aol.com'))
  COMMIT
  &lt;sqlalchemy.engine.ResultProxy object at 0x...&gt;
  </code></pre>
  
  <p>How ever in my design i have several many-to-many relationships. One being between User and Organization. Note i'm using <a href="http://pythonhosted.org/Flask-SQLAlchemy/" rel="nofollow noreferrer">Flask-Sqlalchemy.</a></p>
  
  <pre><code># assuming a relationship like:
  
  # organizations = db.Table('organizations',
  #         db.Column('organization_id', db.Integer, db.ForeignKey('organization.id')),
  #         db.Column('user_id', db.Integer, db.ForeignKey('user.id')))
  # class User(db.Model):
  #     ...
  #     organizations = db.relationship('Organization', secondary=organizations,
  #         backref=db.backref('users', lazy='dynamic'))
  
  # class Organization(db.Model):
  #     ...
  
  def db_reset():
      # lets reset it
      db.drop_all()
      db.create_all()
  
      # establish our connection
      engine = create_engine(SQLALCHEMY_DATABASE_URI)
      conn = engine.connect()
  
      # load in our users
      user_insert = User.__table__insert()
      for user in users: # users is a list of named tuples
          conn.execute(user_insert, name=user.name, role=user.role, 
              organizations= [orgA,orgB,...etc] # how do i do this?
  </code></pre>
  
  <p>So my question is contained in my code as well as my title. How can a build a many to many relationship in using the SQL Expression Language?</p>