This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Commit c1ca9e0
authored
Allow creating database connection wrapper without a singleton (#1120)
* Allow creating database connection wrapper without a singleton
The idea is that one would be able to pass the `_no_singleton` boolean
flag to the class and if so, the class would be returned without
creating a singleton.
This is handy for testing, since it would allow for several connections
to be open in parallel to different database paths, which indeed is a
testing scenario.
```
>>> from codegate.db.connection import DbCodeGate
>>> dbc = DbCodeGate(_no_singleton=True)
>>> print(dbc)
<codegate.db.connection.DbCodeGate object at 0x7f9a0f067650>
>>> dbc2 = DbCodeGate(_no_singleton=True)
>>> print(dbc2)
<codegate.db.connection.DbCodeGate object at 0x7f9a0daad1f0>
>>> dbc3 = DbCodeGate()
>>> print(dbc3)
<codegate.db.connection.DbCodeGate object at 0x7f9a0f065190>
>>> dbc4 = DbCodeGate()
>>> print(dbc4)
<codegate.db.connection.DbCodeGate object at 0x7f9a0f065190>
```
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
* Allow passing args and kwargs to db subclasses
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
---------
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>1 parent d35151d commit c1ca9e0
1 file changed
+11
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
68 | | - | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| |||
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
94 | | - | |
95 | | - | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
519 | 525 | | |
520 | 526 | | |
521 | 527 | | |
522 | | - | |
523 | | - | |
| 528 | + | |
| 529 | + | |
524 | 530 | | |
525 | 531 | | |
526 | 532 | | |
| |||
0 commit comments