Hello, community,
Is there any design pattern used to handle the connection to a database such as an object pooling or Singleton design patterns if no, what is the purpose to don’t use a design pattern that could decrease the database connections.
So the Frappe ORM/ Database API is being refactored to support Postgres. You’ll want to have a clear idea about what version you’re working with so that you don’t try to use pattern that used to exist or doesn’t yet exist. The only source for this kind of information until the new API is finalized is searching the repos.
Foe access to single doctypes, use the get_single_** family of APIs. The data is stored as a blob and has to be translated in and out.
MariaDB [site1.local]> describe tabSingles;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| doctype | varchar(255) | YES | MUL | NULL | |
| field | varchar(255) | YES | | NULL | |
| value | text | YES | | NULL | |
+---------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
Yeah exactly, this what is known as object pooling pattern, this design pattern will guarantee that you are making a limited number of connection instances to database and these object instances can be released when it is done and back to availability on the pool and then will be reused once again when a new connection is requested so that, don’t let the database connection instances reach to number that could break database down.