reydb 1.2.17__py3-none-any.whl → 1.2.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
reydb/rconfig.py CHANGED
@@ -24,7 +24,7 @@ from .rbase import DatabaseBase
24
24
 
25
25
 
26
26
  __all__ = (
27
- 'DatabaseTableConfig',
27
+ 'DatabaseORMTableConfig',
28
28
  'DatabaseConfigSuper',
29
29
  'DatabaseConfig',
30
30
  'DatabaseConfigAsync'
@@ -38,9 +38,9 @@ ConfigValueT = TypeVar('T', bound=ConfigValue) # Any.
38
38
  DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
39
39
 
40
40
 
41
- class DatabaseTableConfig(rorm.Model, table=True):
41
+ class DatabaseORMTableConfig(rorm.Model, table=True):
42
42
  """
43
- Database `config` table model.
43
+ Database `config` table ORM model.
44
44
  """
45
45
 
46
46
  __name__ = 'config'
@@ -59,6 +59,8 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
59
59
  Can create database used `self.build_db` method.
60
60
  """
61
61
 
62
+ _checked: bool = False
63
+
62
64
 
63
65
  def __init__(self, db: DatabaseT) -> None:
64
66
  """
@@ -72,8 +74,16 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
72
74
  # Build.
73
75
  self.db = db
74
76
 
77
+ # Build Database.
78
+ if not self._checked:
79
+ if type(self) == DatabaseConfig:
80
+ self.build_db()
81
+ elif type(self) == DatabaseConfigAsync:
82
+ db.sync_database.config.build_db()
83
+ self._checked = True
84
+
75
85
 
76
- def handle_build_db(self) -> tuple[list[type[DatabaseTableConfig]], list[dict[str, Any]]] :
86
+ def handle_build_db(self) -> tuple[list[type[DatabaseORMTableConfig]], list[dict[str, Any]]] :
77
87
  """
78
88
  Handle method of check and build database tables.
79
89
 
@@ -86,7 +96,7 @@ class DatabaseConfigSuper(DatabaseBase, Generic[DatabaseT]):
86
96
  database = self.db.database
87
97
 
88
98
  ## Table.
89
- tables = [DatabaseTableConfig]
99
+ tables = [DatabaseORMTableConfig]
90
100
 
91
101
  ## View stats.
92
102
  views_stats = [
reydb/rdb.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import TypeVar, Generic
12
+ from typing import TypeVar, Generic, overload
13
13
  from urllib.parse import quote as urllib_quote
14
14
  from pymysql.constants.CLIENT import MULTI_STATEMENTS
15
15
  from sqlalchemy import Engine, create_engine as sqlalchemy_create_engine
@@ -519,6 +519,30 @@ class Database(
519
519
  """
520
520
 
521
521
 
522
+ @property
523
+ def async_database(self) -> 'DatabaseAsync':
524
+ """
525
+ Same engine `DatabaseAsync` instance.
526
+ """
527
+
528
+ # Build.
529
+ db = DatabaseAsync(
530
+ self.host,
531
+ self.port,
532
+ self.username,
533
+ self.password,
534
+ self.database,
535
+ self.pool_size,
536
+ self.max_overflow,
537
+ self.pool_timeout,
538
+ self.pool_recycle,
539
+ self.echo,
540
+ **self.query
541
+ )
542
+
543
+ return db
544
+
545
+
522
546
  class DatabaseAsync(
523
547
  DatabaseSuper[
524
548
  AsyncEngine,
@@ -539,6 +563,30 @@ class DatabaseAsync(
539
563
  """
540
564
 
541
565
 
566
+ @property
567
+ def sync_database(self) -> Database:
568
+ """
569
+ Same engine `Database` instance.
570
+ """
571
+
572
+ # Build.
573
+ db = Database(
574
+ self.host,
575
+ self.port,
576
+ self.username,
577
+ self.password,
578
+ self.database,
579
+ self.pool_size,
580
+ self.max_overflow,
581
+ self.pool_timeout,
582
+ self.pool_recycle,
583
+ self.echo,
584
+ **self.query
585
+ )
586
+
587
+ return db
588
+
589
+
542
590
  async def dispose(self) -> None:
543
591
  """
544
592
  Dispose asynchronous connections.
reydb/rerror.py CHANGED
@@ -22,7 +22,7 @@ from .rbase import DatabaseBase
22
22
 
23
23
 
24
24
  __all__ = (
25
- 'DatabaseTableError',
25
+ 'DatabaseORMTableError',
26
26
  'DatabaseErrorSuper',
27
27
  'DatabaseError',
28
28
  'DatabaseErrorAsync'
@@ -32,9 +32,9 @@ __all__ = (
32
32
  DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
33
33
 
34
34
 
35
- class DatabaseTableError(rorm.Model, table=True):
35
+ class DatabaseORMTableError(rorm.Model, table=True):
36
36
  """
37
- Database `error` table model.
37
+ Database `error` table ORM model.
38
38
  """
39
39
 
40
40
  __name__ = 'error'
@@ -53,6 +53,8 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
53
53
  Can create database used `self.build_db` method.
54
54
  """
55
55
 
56
+ _checked: bool = False
57
+
56
58
 
57
59
  def __init__(self, db: DatabaseT) -> None:
58
60
  """
@@ -66,8 +68,16 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
66
68
  # Build.
67
69
  self.db = db
68
70
 
71
+ # Build Database.
72
+ if not self._checked:
73
+ if type(self) == DatabaseError:
74
+ self.build_db()
75
+ elif type(self) == DatabaseErrorAsync:
76
+ db.sync_database.error.build_db()
77
+ self._checked = True
78
+
69
79
 
70
- def handle_build_db(self) -> tuple[list[type[DatabaseTableError]], list[dict[str, Any]]]:
80
+ def handle_build_db(self) -> tuple[list[type[DatabaseORMTableError]], list[dict[str, Any]]]:
71
81
  """
72
82
  Handle method of check and build database tables.
73
83
 
@@ -80,7 +90,7 @@ class DatabaseErrorSuper(DatabaseBase, Generic[DatabaseT]):
80
90
  database = self.db.database
81
91
 
82
92
  ## Table.
83
- tables = [DatabaseTableError]
93
+ tables = [DatabaseORMTableError]
84
94
 
85
95
  ## View stats.
86
96
  views_stats = [
reydb/rexec.py CHANGED
@@ -28,7 +28,6 @@ from .rbase import DatabaseBase, handle_sql, handle_data
28
28
 
29
29
  __all__ = (
30
30
  'Result',
31
- 'ResultORM',
32
31
  'DatabaseExecuteSuper',
33
32
  'DatabaseExecute',
34
33
  'DatabaseExecuteAsync'
reydb/rorm.py CHANGED
@@ -560,32 +560,12 @@ class DatabaseORMSuper(DatabaseORMBase, Generic[DatabaseT, DatabaseORMSessionT])
560
560
  class DatabaseORM(DatabaseORMSuper['rdb.Database', 'DatabaseORMSession']):
561
561
  """
562
562
  Database ORM type.
563
-
564
- Attributes
565
- ----------
566
- metaData : Registry metadata instance.
567
- DatabaseModel : Database ORM model type.
568
- Field : Database ORM model field type.
569
- Config : Database ORM model config type.
570
- types : Database ORM model filed types module.
571
- wrap_validate_model : Create decorator of validate database ORM model.
572
- wrap_validate_filed : Create decorator of validate database ORM model field.
573
563
  """
574
564
 
575
565
 
576
566
  class DatabaseORMAsync(DatabaseORMSuper['rdb.DatabaseAsync', 'DatabaseORMSessionAsync']):
577
567
  """
578
568
  Asynchronous database ORM type.
579
-
580
- Attributes
581
- ----------
582
- metaData : Registry metadata instance.
583
- DatabaseModel : Database ORM model type.
584
- Field : Database ORM model field type.
585
- Config : Database ORM model config type.
586
- types : Database ORM model filed types module.
587
- wrap_validate_model : Create decorator of validate database ORM model.
588
- wrap_validate_filed : Create decorator of validate database ORM model field.
589
569
  """
590
570
 
591
571
 
@@ -1607,13 +1587,10 @@ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsyn
1607
1587
  class DatabaseORMStatementSelectSuper(DatabaseORMStatementSuper, Select):
1608
1588
  """
1609
1589
  Database ORM `select` statement super type.
1610
-
1611
- Attributes
1612
- ----------
1613
- inherit_cache : Compatible type.
1614
1590
  """
1615
1591
 
1616
1592
  inherit_cache: Final = True
1593
+ 'Compatible type.'
1617
1594
 
1618
1595
 
1619
1596
  def fields(self, *names: str) -> Self:
@@ -1672,13 +1649,10 @@ class DatabaseORMStatementSelectSuper(DatabaseORMStatementSuper, Select):
1672
1649
  class DatabaseORMStatementSelect(DatabaseORMStatement, DatabaseORMStatementSelectSuper, Generic[DatabaseORMModelT]):
1673
1650
  """
1674
1651
  Database ORM `select` statement type.
1675
-
1676
- Attributes
1677
- ----------
1678
- inherit_cache : Compatible type.
1679
1652
  """
1680
1653
 
1681
1654
  inherit_cache: Final = True
1655
+ 'Compatible type.'
1682
1656
 
1683
1657
 
1684
1658
  @overload
@@ -1690,13 +1664,10 @@ class DatabaseORMStatementSelect(DatabaseORMStatement, DatabaseORMStatementSelec
1690
1664
  class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync, DatabaseORMStatementSelectSuper, Generic[DatabaseORMModelT]):
1691
1665
  """
1692
1666
  Asynchronous database ORM `select` statement type.
1693
-
1694
- Attributes
1695
- ----------
1696
- inherit_cache : Compatible type.
1697
1667
  """
1698
1668
 
1699
1669
  inherit_cache: Final = True
1670
+ 'Compatible type.'
1700
1671
 
1701
1672
 
1702
1673
  @overload
@@ -1708,13 +1679,10 @@ class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync, DatabaseORMStat
1708
1679
  class DatabaseORMStatementInsertSuper(DatabaseORMStatementSuper, Insert):
1709
1680
  """
1710
1681
  Database ORM `select` statement super type.
1711
-
1712
- Attributes
1713
- ----------
1714
- inherit_cache : Compatible type.
1715
1682
  """
1716
1683
 
1717
1684
  inherit_cache: Final = True
1685
+ 'Compatible type.'
1718
1686
 
1719
1687
 
1720
1688
  def ignore(self) -> Self:
@@ -1794,37 +1762,28 @@ class DatabaseORMStatementInsertSuper(DatabaseORMStatementSuper, Insert):
1794
1762
  class DatabaseORMStatementInsert(DatabaseORMStatement, DatabaseORMStatementInsertSuper):
1795
1763
  """
1796
1764
  Database ORM `insert` statement type.
1797
-
1798
- Attributes
1799
- ----------
1800
- inherit_cache : Compatible type.
1801
1765
  """
1802
1766
 
1803
1767
  inherit_cache: Final = True
1768
+ 'Compatible type.'
1804
1769
 
1805
1770
 
1806
1771
  class DatabaseORMStatementInsertAsync(DatabaseORMStatementAsync, DatabaseORMStatementInsertSuper):
1807
1772
  """
1808
1773
  Asynchronous database ORM `insert` statement type.
1809
-
1810
- Attributes
1811
- ----------
1812
- inherit_cache : Compatible type.
1813
1774
  """
1814
1775
 
1815
1776
  inherit_cache: Final = True
1777
+ 'Compatible type.'
1816
1778
 
1817
1779
 
1818
1780
  class DatabaseORMStatementUpdateSuper(DatabaseORMStatementSuper, Update):
1819
1781
  """
1820
1782
  Database ORM `update` statement super type.
1821
-
1822
- Attributes
1823
- ----------
1824
- inherit_cache : Compatible type.
1825
1783
  """
1826
1784
 
1827
1785
  inherit_cache: Final = True
1786
+ 'Compatible type.'
1828
1787
 
1829
1788
 
1830
1789
  def where(self, *clauses: str | _ColumnExpressionArgument[bool]) -> Self:
@@ -1878,37 +1837,28 @@ class DatabaseORMStatementUpdateSuper(DatabaseORMStatementSuper, Update):
1878
1837
  class DatabaseORMStatementUpdate(DatabaseORMStatement, DatabaseORMStatementUpdateSuper):
1879
1838
  """
1880
1839
  Database ORM `update` statement type.
1881
-
1882
- Attributes
1883
- ----------
1884
- inherit_cache : Compatible type.
1885
1840
  """
1886
1841
 
1887
1842
  inherit_cache: Final = True
1843
+ 'Compatible type.'
1888
1844
 
1889
1845
 
1890
1846
  class DatabaseORMStatementUpdateAsync(DatabaseORMStatementAsync, DatabaseORMStatementUpdateSuper):
1891
1847
  """
1892
1848
  Asynchronous database ORM `update` statement type.
1893
-
1894
- Attributes
1895
- ----------
1896
- inherit_cache : Compatible type.
1897
1849
  """
1898
1850
 
1899
1851
  inherit_cache: Final = True
1852
+ 'Compatible type.'
1900
1853
 
1901
1854
 
1902
1855
  class DatabaseORMStatementDeleteSuper(DatabaseORMStatementSuper, Delete):
1903
1856
  """
1904
1857
  Database ORM `delete` statement super type.
1905
-
1906
- Attributes
1907
- ----------
1908
- inherit_cache : Compatible type.
1909
1858
  """
1910
1859
 
1911
1860
  inherit_cache: Final = True
1861
+ 'Compatible type.'
1912
1862
 
1913
1863
 
1914
1864
  def where(self, *clauses: str | _ColumnExpressionArgument[bool]) -> Self:
@@ -1962,25 +1912,19 @@ class DatabaseORMStatementDeleteSuper(DatabaseORMStatementSuper, Delete):
1962
1912
  class DatabaseORMStatementDelete(DatabaseORMStatement, DatabaseORMStatementDeleteSuper):
1963
1913
  """
1964
1914
  Database ORM `delete` statement type.
1965
-
1966
- Attributes
1967
- ----------
1968
- inherit_cache : Compatible type.
1969
1915
  """
1970
1916
 
1971
1917
  inherit_cache: Final = True
1918
+ 'Compatible type.'
1972
1919
 
1973
1920
 
1974
1921
  class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync, DatabaseORMStatementDeleteSuper):
1975
1922
  """
1976
1923
  Asynchronous database ORM `delete` statement type.
1977
-
1978
- Attributes
1979
- ----------
1980
- inherit_cache : Compatible type.
1981
1924
  """
1982
1925
 
1983
1926
  inherit_cache: Final = True
1927
+ 'Compatible type.'
1984
1928
 
1985
1929
 
1986
1930
  # Simple path.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reydb
3
- Version: 1.2.17
3
+ Version: 1.2.18
4
4
  Summary: Database method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reydb/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -0,0 +1,15 @@
1
+ reydb/__init__.py,sha256=MJkZy2rOM2VSj_L2kaKe6CJfsg334vb3OLVUqavWKfM,558
2
+ reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
3
+ reydb/rbase.py,sha256=sl2lZWQVC5kXTJid2v5zmy1lMshYLm2NhEQi_dnY_Bw,8232
4
+ reydb/rbuild.py,sha256=QZF26KDL6oRb6RyMEtIJcbiX9TJzK2aUPqjqGjflF7s,80834
5
+ reydb/rconfig.py,sha256=cPFt9QI_lj0u4tChBJ0kHYf2G788epbT2oSYk2r24yo,18010
6
+ reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
7
+ reydb/rdb.py,sha256=nieXxFqf07Dljl-12Ub8R8s-uNZjai7PN2rqlvOxyqw,15408
8
+ reydb/rerror.py,sha256=O7lbnkAamQa1OKz6WJPeBUkzDTP6LNGqBqCfrI02DO4,14722
9
+ reydb/rexec.py,sha256=uj87vAeKnqNg9tWCy0ycjI9uMj0IgZCS4waL9cC_mTY,52930
10
+ reydb/rinfo.py,sha256=1lMnD-eN97vHrQ1DM8X7mQIhyLmCg6V0P2QwSeF07_c,18127
11
+ reydb/rorm.py,sha256=-pb5SJBk2WOluWC0ci0OOCOKOj2MIxoy3oVRJ7whpFQ,49337
12
+ reydb-1.2.18.dist-info/METADATA,sha256=SCX11Jre4BRem7gUw8lqaZ495-pNgrqhz45C3-3V4Ws,1647
13
+ reydb-1.2.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ reydb-1.2.18.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
15
+ reydb-1.2.18.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- reydb/__init__.py,sha256=MJkZy2rOM2VSj_L2kaKe6CJfsg334vb3OLVUqavWKfM,558
2
- reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
3
- reydb/rbase.py,sha256=sl2lZWQVC5kXTJid2v5zmy1lMshYLm2NhEQi_dnY_Bw,8232
4
- reydb/rbuild.py,sha256=QZF26KDL6oRb6RyMEtIJcbiX9TJzK2aUPqjqGjflF7s,80834
5
- reydb/rconfig.py,sha256=ZmVpoP7GuwuP3536Lz34kaZDG5MCVf0JFBaT5nm1-L8,17686
6
- reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
7
- reydb/rdb.py,sha256=s96XLLH8ZmJm-q4J9RRP6KGkxH3MGodPOcWqB-6-V4U,14356
8
- reydb/rerror.py,sha256=0AIe7ZpDEe60xTV_FJCCBwzFVHwONh7qxvYpgwzZDvI,14401
9
- reydb/rexec.py,sha256=DdmcJ6j4il06wEyvhttac2GpmGdsZJtOEljH7wUvca8,52948
10
- reydb/rinfo.py,sha256=1lMnD-eN97vHrQ1DM8X7mQIhyLmCg6V0P2QwSeF07_c,18127
11
- reydb/rorm.py,sha256=77QQgQglvA2b4fRH1xBqca7BQ-Hu2MudDopRPJ6E4J4,50761
12
- reydb-1.2.17.dist-info/METADATA,sha256=zfoqQQNi3sPymiV82KzaBJS_-c4ZA_3r2VIMq9xK3WU,1647
13
- reydb-1.2.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- reydb-1.2.17.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
15
- reydb-1.2.17.dist-info/RECORD,,
File without changes