active-alchemy icon indicating copy to clipboard operation
active-alchemy copied to clipboard

Can't validate argument 'bind_key'

Open one-more-alex opened this issue 9 years ago • 1 comments

After connecting active-sqlalchemy I got strange warnings:

/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py:552: SAWarning: Can't validate argument 'bind_key'; can't locate any SQLAlchemy dialect named 'bind' self._validate_dialect_kwargs(kwargs)

  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  • Restarting with stat /usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py:552: SAWarning: Can't validate argument 'bind_key'; can't locate any SQLAlchemy dialect named 'bind' self._validate_dialect_kwargs(kwargs)

one-more-alex avatar May 11 '15 10:05 one-more-alex

I am also having this issue.

from active_alchemy import SQLAlchemy
from flask import Flask

app = Flask(__name__)
db = SQLAlchemy('mysql+mysqldb://admin:[email protected]:3306/my_database', app=app)

event_participants = db.Table(
    'event_participants', db.metadata,
    db.Column('event_id', db.Integer, db.ForeignKey('events.id')),
    db.Column('person_id', db.Integer, db.ForeignKey('persons.id')))


class Event(db.Model):
    __tablename__ = 'events'
    id = db.Column(db.Integer, primary_key=True)
    participants = db.relationship('Person',
                                   secondary='event_participants',
                                   backref='participating')


class Person(db.Model):
    __tablename__ = 'persons'
    id = db.Column(db.Integer, primary_key=True)

if __name__ == '__main__':
    app.run()

When I run this tiny representative example code I get the following warning:

$ python example.py
/path/to/my/site-packages/sqlalchemy/sql/base.py:291: SAWarning: Can't validate argument 'bind_key'; can't locate any SQLAlchemy dialect named 'bind'
  (k, dialect_name))
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

In this example I am setting up a many-to-many relationship between events and persons. Meaning 1) there can be many events a person is participating in and 2) many persons can be attending an event. Documentation for setting up this kind of relationship with SQLAlchemy can be found here: http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html#many-to-many which is what the structure for my example code is based on.

lexicalunit avatar Jan 21 '16 17:01 lexicalunit