Ok, let me try rephrasing my question.
Is binding an engine/connection simultaneously to a Session and a Table
considered bad practice? I've looked up the documentation but not
sufficiently confident about this. There seems no definite/official answer
to this. Could some experienced users help give a definite clue here?
Thanks.
On Sunday, March 9, 2014 12:08:42 AM UTC-8, Bao Niu wrote:
>
> From reading the documentation I learned that you can either bind an
> engine to a session:
> >>>engine = create_engine('sqlite:///{}'.format(dbPath), echo=False)
> >>>Session = sessionmaker(bind=engine)
>
> or to a declarative_base:
> >>>engine = create_engine('sqlite:///{}'.format(dbPath), echo=False)
> >>>Sqlalchemy_base = declarative_base(engine)
>
> Is there a best practice like always binding to a session?
> I currently bind the engine to both:
> >>>engine = create_engine('sqlite:///{}'.format(dbPath), echo=False)
> >>>Session = sessionmaker(bind=engine)
> >>>Sqlalchemy_base = declarative_base(engine)
> From running my codes I didn't encounter any problem. But I wonder how
> SqlAlchemy resolves the conflict internally if there are two bindings? Is
> there some potential problems down the road if I kept using this manner?
> Thanks.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.