Do peewee models automatically close the connection?

I am using peewee to access SQLite DB.

I did model.pyas:

from peewee import *

db = SqliteDatabase('people.db')

class Person(Model):
    name = CharField()
    birthday = DateField()
    is_relative = BooleanField()

    class Meta:
        database = db

In another Python file (c import model), I then manipulate the database using calls like Person.create()or Person.select(name=='Joe').delete_instance().

Quickstart says at the end to call db.close()to close the connection. Does this apply to my case? Should I call something like model.db.close()?

+4
source share
2 answers

You open and close the connection manually:

In your case (s db = SqliteDatabase('people.db'))

You have established a connection to the database:

db.connect()

, , , , , :

db.close()
0

, peewee , . , -, , , , , Main-Thread.

. , , :

:

2006: MySQL

:

, , , , , . , - , - , , .

: №.

0

Source: https://habr.com/ru/post/1667234/


All Articles