[PonyORM-list] Example with disconnect()

Gamesbrainiac gamesbrainiac at gmail.com
Thu Dec 11 05:41:15 UTC 2014


I agree, it is better to use the context manager provided.

On Thu, Dec 11, 2014 at 5:06 AM, Alexander Kozlovsky <
alexander.kozlovsky at gmail.com> wrote:

> 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",
> db="mydb")
>
>     class Person(db.Entity):
>         name = Required(str)
>
>     db.generate_mapping(create_tables=True)
>
>     with db_session:
>         p1 = Person(name='John')
>
>     db.disconnect()
>
>
> 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.
>
>
> Regards,
> 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
>>
>>
>
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
>
>


-- 
Kind Regards,

Quazi Nafiul Islam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20141211/5a772037/attachment.html>


More information about the ponyorm-list mailing list