Giter Site home page Giter Site logo

Comments (1)

lexicalunit avatar lexicalunit commented on June 24, 2024 6

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.

from active-alchemy.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.