[PonyORM-list] Example with disconnect()

Alexander Kozlovsky alexander.kozlovsky at gmail.com
Wed Dec 10 23:06:01 UTC 2014

Hi Arthur!

For what purpose do you want to use `disconnect` method? I'm not sure I
correctly understand what example you want to see, but the simplest example
of `disconnect` method is this:

    from pony.orm import *

    db = Database('mysql', host="myhost", user="me", passwd="123",

    class Person(db.Entity):
        name = Required(str)


    with db_session:
        p1 = Person(name='John')


The disconnect method works for current thread only. It releases connection
to the server which db object holds in its connection pool.

This method should be called outside of any db session.

If you application is multi-threaded and you want to disconnect your db
object from the database, the you need to call `disconnect` method from
each thread in which you have worked with the entities of this db object.

Alexander Kozlovsky

On Wed, Dec 10, 2014 at 5:39 AM, Goldberg, Arthur P <
arthur.p.goldberg at mssm.edu> wrote:

>  Hi Guys
>  Could you please show an example with disconnect()? I'm using a couple
> of dbmses in one SQL server, and getting
>  Database object was already bound to MySQL provider
> Sorry, I'm too rushed to debug carefully.
>  Yhanks
> A
>            ---
> Arthur Goldberg
> Associate Professor of Psychiatry
> Seaver Autism Center and Icahn Institute for Genomics & Multiscale Biology
> Icahn School of Medicine at Mount Sinai
>  Seaver Center, Room ABE-33
>  212-241-4229
> Arthur.Goldberg at mssm.edu
>  Follow us on Twitter @IcahnInstitute <https://twitter.com/IcahnInstitute>
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20141211/c9a870e0/attachment-0001.html>

More information about the ponyorm-list mailing list