reydb 1.1.27__py3-none-any.whl → 1.1.29__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/__init__.py +1 -0
- reydb/rall.py +1 -0
- reydb/rbase.py +2 -2
- reydb/rbuild.py +17 -14
- reydb/rconn.py +4 -11
- reydb/rdb.py +76 -59
- reydb/rexec.py +23 -23
- reydb/rfile.py +40 -15
- reydb/rinfo.py +55 -55
- reydb/rlog.py +303 -0
- reydb/rparam.py +14 -13
- {reydb-1.1.27.dist-info → reydb-1.1.29.dist-info}/METADATA +1 -1
- reydb-1.1.29.dist-info/RECORD +15 -0
- reydb-1.1.27.dist-info/RECORD +0 -14
- {reydb-1.1.27.dist-info → reydb-1.1.29.dist-info}/WHEEL +0 -0
- {reydb-1.1.27.dist-info → reydb-1.1.29.dist-info}/licenses/LICENSE +0 -0
reydb/__init__.py
CHANGED
reydb/rall.py
CHANGED
reydb/rbase.py
CHANGED
reydb/rbuild.py
CHANGED
@@ -14,13 +14,13 @@ from copy import deepcopy
|
|
14
14
|
from reykit.rbase import throw
|
15
15
|
from reykit.rstdout import ask
|
16
16
|
|
17
|
-
from .rbase import
|
18
|
-
from .rconn import
|
17
|
+
from .rbase import DatabaseBase
|
18
|
+
from .rconn import DatabaseConnection
|
19
19
|
from .rdb import Database
|
20
20
|
|
21
21
|
|
22
22
|
__all__ = (
|
23
|
-
'
|
23
|
+
'DatabaseBuild',
|
24
24
|
)
|
25
25
|
|
26
26
|
|
@@ -46,19 +46,19 @@ IndexSet = TypedDict(
|
|
46
46
|
)
|
47
47
|
|
48
48
|
|
49
|
-
class
|
49
|
+
class DatabaseBuild(DatabaseBase):
|
50
50
|
"""
|
51
51
|
Database build type.
|
52
52
|
"""
|
53
53
|
|
54
54
|
|
55
|
-
def __init__(self, rdatabase: Database |
|
55
|
+
def __init__(self, rdatabase: Database | DatabaseConnection) -> None:
|
56
56
|
"""
|
57
57
|
Build instance attributes.
|
58
58
|
|
59
59
|
Parameters
|
60
60
|
----------
|
61
|
-
rdatabase : Database or
|
61
|
+
rdatabase : Database or DatabaseConnection instance.
|
62
62
|
"""
|
63
63
|
|
64
64
|
# SQLite.
|
@@ -994,15 +994,18 @@ class DBBuild(BaseDatabase):
|
|
994
994
|
self._schema = self.rdatabase.schema(False)
|
995
995
|
|
996
996
|
# Judge.
|
997
|
-
judge =
|
998
|
-
|
999
|
-
|
1000
|
-
table is
|
1001
|
-
|
997
|
+
judge = (
|
998
|
+
database in self._schema
|
999
|
+
and (
|
1000
|
+
table is None
|
1001
|
+
or (
|
1002
|
+
(database_info := self._schema.get(database)) is not None
|
1003
|
+
and (table_info := database_info.get(table)) is not None
|
1004
|
+
)
|
1002
1005
|
)
|
1003
|
-
|
1004
|
-
column is
|
1005
|
-
|
1006
|
+
and (
|
1007
|
+
column is None
|
1008
|
+
or column in table_info
|
1006
1009
|
)
|
1007
1010
|
)
|
1008
1011
|
|
reydb/rconn.py
CHANGED
@@ -10,13 +10,9 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
from typing import Any, Self
|
13
|
-
from types import TracebackType
|
14
|
-
from sqlalchemy import text as sqlalchemy_text
|
15
13
|
from sqlalchemy.engine.base import Connection
|
16
|
-
from sqlalchemy.engine.cursor import CursorResult
|
17
14
|
from sqlalchemy.sql.elements import TextClause
|
18
15
|
from sqlalchemy.exc import OperationalError
|
19
|
-
from pandas import DataFrame
|
20
16
|
from reykit.rbase import get_first_notnone
|
21
17
|
from reykit.rdata import objs_in
|
22
18
|
from reykit.rstdout import echo
|
@@ -27,11 +23,11 @@ from .rdb import Result, Database
|
|
27
23
|
|
28
24
|
|
29
25
|
__all__ = (
|
30
|
-
'
|
26
|
+
'DatabaseConnection',
|
31
27
|
)
|
32
28
|
|
33
29
|
|
34
|
-
class
|
30
|
+
class DatabaseConnection(Database):
|
35
31
|
"""
|
36
32
|
Database connection type.
|
37
33
|
"""
|
@@ -177,7 +173,7 @@ class DBConnection(Database):
|
|
177
173
|
):
|
178
174
|
text = 'Retrying...'
|
179
175
|
title = 'Database Execute Operational Error'
|
180
|
-
handler = lambda
|
176
|
+
handler = lambda exc_text, *_: echo(exc_text, text, title=title, frame='top')
|
181
177
|
executor = wrap_retry(self.executor, handler=handler, exception=OperationalError)
|
182
178
|
result = executor(self.connection, sql, data, report)
|
183
179
|
|
@@ -236,8 +232,7 @@ class DBConnection(Database):
|
|
236
232
|
def __exit__(
|
237
233
|
self,
|
238
234
|
exc_type: type[BaseException] | None,
|
239
|
-
|
240
|
-
exc_traceback: TracebackType | None
|
235
|
+
*_
|
241
236
|
) -> None:
|
242
237
|
"""
|
243
238
|
Exit syntax `with`.
|
@@ -245,8 +240,6 @@ class DBConnection(Database):
|
|
245
240
|
Parameters
|
246
241
|
----------
|
247
242
|
exc_type : Exception type.
|
248
|
-
exc_instance : Exception instance.
|
249
|
-
exc_traceback : Exception traceback instance.
|
250
243
|
"""
|
251
244
|
|
252
245
|
# Commit.
|
reydb/rdb.py
CHANGED
@@ -9,17 +9,15 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Any, Literal,
|
12
|
+
from typing import Any, Literal, overload
|
13
13
|
from collections.abc import Iterable, Generator
|
14
14
|
from enum import EnumType
|
15
15
|
from urllib.parse import quote as urllib_quote
|
16
16
|
from sqlalchemy import create_engine as sqlalchemy_create_engine, text as sqlalchemy_text
|
17
17
|
from sqlalchemy.engine.base import Engine, Connection
|
18
|
-
from sqlalchemy.engine.cursor import CursorResult
|
19
18
|
from sqlalchemy.engine.url import URL
|
20
19
|
from sqlalchemy.sql.elements import TextClause
|
21
20
|
from sqlalchemy.exc import OperationalError
|
22
|
-
from pandas import DataFrame
|
23
21
|
from reykit.rbase import throw, is_iterable, get_first_notnone
|
24
22
|
from reykit.rdata import Generator, to_json
|
25
23
|
from reykit.rmonkey import monkey_sqlalchemy_result_more_fetch, monkey_sqlalchemy_row_index_field
|
@@ -29,7 +27,7 @@ from reykit.rtable import TableData, Table
|
|
29
27
|
from reykit.rtext import join_data_text
|
30
28
|
from reykit.rwrap import wrap_runtime, wrap_retry
|
31
29
|
|
32
|
-
from .rbase import
|
30
|
+
from .rbase import DatabaseBase
|
33
31
|
|
34
32
|
|
35
33
|
__all__ = (
|
@@ -44,7 +42,7 @@ Result = Result_
|
|
44
42
|
monkey_sqlalchemy_row_index_field()
|
45
43
|
|
46
44
|
|
47
|
-
class Database(
|
45
|
+
class Database(DatabaseBase):
|
48
46
|
"""
|
49
47
|
Database type.
|
50
48
|
|
@@ -887,7 +885,7 @@ class Database(BaseDatabase):
|
|
887
885
|
):
|
888
886
|
text = 'Retrying...'
|
889
887
|
title = 'Database Execute Operational Error'
|
890
|
-
handler = lambda
|
888
|
+
handler = lambda exc_text, *_: echo(exc_text, text, title=title, frame='top')
|
891
889
|
executor = wrap_retry(self.executor, handler=handler, exception=OperationalError)
|
892
890
|
result = executor(self.connection, sql, data, report)
|
893
891
|
|
@@ -1689,7 +1687,7 @@ class Database(BaseDatabase):
|
|
1689
1687
|
|
1690
1688
|
def connect(self):
|
1691
1689
|
"""
|
1692
|
-
Build instance
|
1690
|
+
Build `DatabaseConnection` instance.
|
1693
1691
|
|
1694
1692
|
Returns
|
1695
1693
|
-------
|
@@ -1697,10 +1695,10 @@ class Database(BaseDatabase):
|
|
1697
1695
|
"""
|
1698
1696
|
|
1699
1697
|
# Import.
|
1700
|
-
from .rconn import
|
1698
|
+
from .rconn import DatabaseConnection
|
1701
1699
|
|
1702
1700
|
# Build.
|
1703
|
-
dbconnection =
|
1701
|
+
dbconnection = DatabaseConnection(
|
1704
1702
|
self.engine.connect(),
|
1705
1703
|
self
|
1706
1704
|
)
|
@@ -1721,51 +1719,51 @@ class Database(BaseDatabase):
|
|
1721
1719
|
--------
|
1722
1720
|
Execute.
|
1723
1721
|
>>> sql = 'select :value'
|
1724
|
-
>>> result =
|
1722
|
+
>>> result = DatabaseExecute(sql, value=1)
|
1725
1723
|
|
1726
1724
|
Select.
|
1727
1725
|
>>> field = ['id', 'value']
|
1728
1726
|
>>> where = '`id` = ids'
|
1729
1727
|
>>> ids = (1, 2)
|
1730
|
-
>>> result =
|
1728
|
+
>>> result = DatabaseExecute.database.table(field, where, ids=ids)
|
1731
1729
|
|
1732
1730
|
Insert.
|
1733
1731
|
>>> data = [{'id': 1}, {'id': 2}]
|
1734
1732
|
>>> duplicate = 'ignore'
|
1735
|
-
>>> result =
|
1736
|
-
>>> result =
|
1737
|
-
>>> result =
|
1733
|
+
>>> result = DatabaseExecute.database.table + data
|
1734
|
+
>>> result = DatabaseExecute.database.table + (data, duplicate)
|
1735
|
+
>>> result = DatabaseExecute.database.table + {'data': data, 'duplicate': duplicate}
|
1738
1736
|
|
1739
1737
|
Update.
|
1740
1738
|
>>> data = [{'name': 'a', 'id': 1}, {'name': 'b', 'id': 2}]
|
1741
1739
|
>>> where_fields = 'id'
|
1742
|
-
>>> result =
|
1743
|
-
>>> result =
|
1744
|
-
>>> result =
|
1740
|
+
>>> result = DatabaseExecute.database.table & data
|
1741
|
+
>>> result = DatabaseExecute.database.table & (data, where_fields)
|
1742
|
+
>>> result = DatabaseExecute.database.table & {'data': data, 'where_fields': where_fields}
|
1745
1743
|
|
1746
1744
|
Delete.
|
1747
1745
|
>>> where = '`id` IN (1, 2)'
|
1748
1746
|
>>> report = True
|
1749
|
-
>>> result =
|
1750
|
-
>>> result =
|
1751
|
-
>>> result =
|
1747
|
+
>>> result = DatabaseExecute.database.table - where
|
1748
|
+
>>> result = DatabaseExecute.database.table - (where, report)
|
1749
|
+
>>> result = DatabaseExecute.database.table - {'where': where, 'report': report}
|
1752
1750
|
|
1753
1751
|
Copy.
|
1754
1752
|
>>> where = '`id` IN (1, 2)'
|
1755
1753
|
>>> limit = 1
|
1756
|
-
>>> result =
|
1757
|
-
>>> result =
|
1758
|
-
>>> result =
|
1754
|
+
>>> result = DatabaseExecute.database.table * where
|
1755
|
+
>>> result = DatabaseExecute.database.table * (where, limit)
|
1756
|
+
>>> result = DatabaseExecute.database.table * {'where': where, 'limit': limit}
|
1759
1757
|
|
1760
1758
|
Exist.
|
1761
1759
|
>>> where = '`id` IN (1, 2)'
|
1762
1760
|
>>> report = True
|
1763
|
-
>>> result = where in
|
1764
|
-
>>> result = (where, report) in
|
1765
|
-
>>> result = {'where': where, 'report': report} in
|
1761
|
+
>>> result = where in DatabaseExecute.database.table
|
1762
|
+
>>> result = (where, report) in DatabaseExecute.database.table
|
1763
|
+
>>> result = {'where': where, 'report': report} in DatabaseExecute.database.table
|
1766
1764
|
|
1767
1765
|
Count.
|
1768
|
-
>>> result = len(
|
1766
|
+
>>> result = len(DatabaseExecute.database.table)
|
1769
1767
|
|
1770
1768
|
Default database.
|
1771
1769
|
>>> field = ['id', 'value']
|
@@ -1774,10 +1772,10 @@ class Database(BaseDatabase):
|
|
1774
1772
|
"""
|
1775
1773
|
|
1776
1774
|
# Import.
|
1777
|
-
from .rexec import
|
1775
|
+
from .rexec import DatabaseExecute
|
1778
1776
|
|
1779
1777
|
# Build.
|
1780
|
-
dbexecute =
|
1778
|
+
dbexecute = DatabaseExecute(self)
|
1781
1779
|
|
1782
1780
|
return dbexecute
|
1783
1781
|
|
@@ -1859,7 +1857,7 @@ class Database(BaseDatabase):
|
|
1859
1857
|
@property
|
1860
1858
|
def info(self):
|
1861
1859
|
"""
|
1862
|
-
Build instance
|
1860
|
+
Build `DatabaseInformationSchema` instance.
|
1863
1861
|
|
1864
1862
|
Returns
|
1865
1863
|
-------
|
@@ -1868,29 +1866,29 @@ class Database(BaseDatabase):
|
|
1868
1866
|
Examples
|
1869
1867
|
--------
|
1870
1868
|
Get databases information of server.
|
1871
|
-
>>> databases_info =
|
1869
|
+
>>> databases_info = DatabaseInformationSchema()
|
1872
1870
|
|
1873
1871
|
Get tables information of database.
|
1874
|
-
>>> tables_info =
|
1872
|
+
>>> tables_info = DatabaseInformationSchema.database()
|
1875
1873
|
|
1876
1874
|
Get columns information of table.
|
1877
|
-
>>> columns_info =
|
1875
|
+
>>> columns_info = DatabaseInformationSchema.database.table()
|
1878
1876
|
|
1879
1877
|
Get database attribute.
|
1880
|
-
>>> database_attr =
|
1878
|
+
>>> database_attr = DatabaseInformationSchema.database['attribute']
|
1881
1879
|
|
1882
1880
|
Get table attribute.
|
1883
|
-
>>> database_attr =
|
1881
|
+
>>> database_attr = DatabaseInformationSchema.database.table['attribute']
|
1884
1882
|
|
1885
1883
|
Get column attribute.
|
1886
|
-
>>> database_attr =
|
1884
|
+
>>> database_attr = DatabaseInformationSchema.database.table.column['attribute']
|
1887
1885
|
"""
|
1888
1886
|
|
1889
1887
|
# Import.
|
1890
|
-
from .rinfo import
|
1888
|
+
from .rinfo import DatabaseInformationSchema
|
1891
1889
|
|
1892
1890
|
# Build.
|
1893
|
-
dbischema =
|
1891
|
+
dbischema = DatabaseInformationSchema(self)
|
1894
1892
|
|
1895
1893
|
return dbischema
|
1896
1894
|
|
@@ -1898,7 +1896,7 @@ class Database(BaseDatabase):
|
|
1898
1896
|
@property
|
1899
1897
|
def build(self):
|
1900
1898
|
"""
|
1901
|
-
Build instance
|
1899
|
+
Build `DatabaseBuild` instance.
|
1902
1900
|
|
1903
1901
|
Returns
|
1904
1902
|
-------
|
@@ -1906,10 +1904,10 @@ class Database(BaseDatabase):
|
|
1906
1904
|
"""
|
1907
1905
|
|
1908
1906
|
# Import.
|
1909
|
-
from .rbuild import
|
1907
|
+
from .rbuild import DatabaseBuild
|
1910
1908
|
|
1911
1909
|
# Build.
|
1912
|
-
dbbuild =
|
1910
|
+
dbbuild = DatabaseBuild(self)
|
1913
1911
|
|
1914
1912
|
return dbbuild
|
1915
1913
|
|
@@ -1917,7 +1915,7 @@ class Database(BaseDatabase):
|
|
1917
1915
|
@property
|
1918
1916
|
def file(self):
|
1919
1917
|
"""
|
1920
|
-
Build instance
|
1918
|
+
Build `DatabaseFile` instance.
|
1921
1919
|
|
1922
1920
|
Returns
|
1923
1921
|
-------
|
@@ -1925,10 +1923,29 @@ class Database(BaseDatabase):
|
|
1925
1923
|
"""
|
1926
1924
|
|
1927
1925
|
# Import.
|
1928
|
-
from .rfile import
|
1926
|
+
from .rfile import DatabaseFile
|
1929
1927
|
|
1930
1928
|
# Build.
|
1931
|
-
dbfile =
|
1929
|
+
dbfile = DatabaseFile(self)
|
1930
|
+
|
1931
|
+
return dbfile
|
1932
|
+
|
1933
|
+
|
1934
|
+
@property
|
1935
|
+
def log(self):
|
1936
|
+
"""
|
1937
|
+
Build `DatabaseLog` instance.
|
1938
|
+
|
1939
|
+
Returns
|
1940
|
+
-------
|
1941
|
+
Database file instance.
|
1942
|
+
"""
|
1943
|
+
|
1944
|
+
# Import.
|
1945
|
+
from .rlog import DatabaseLog
|
1946
|
+
|
1947
|
+
# Build.
|
1948
|
+
dbfile = DatabaseLog(self)
|
1932
1949
|
|
1933
1950
|
return dbfile
|
1934
1951
|
|
@@ -1936,7 +1953,7 @@ class Database(BaseDatabase):
|
|
1936
1953
|
@property
|
1937
1954
|
def status(self):
|
1938
1955
|
"""
|
1939
|
-
Build instance
|
1956
|
+
Build `DatabaseParameterStatus` or `DatabaseParameterPragma` instance.
|
1940
1957
|
|
1941
1958
|
Returns
|
1942
1959
|
-------
|
@@ -1944,17 +1961,17 @@ class Database(BaseDatabase):
|
|
1944
1961
|
"""
|
1945
1962
|
|
1946
1963
|
# Import.
|
1947
|
-
from .rparam import
|
1964
|
+
from .rparam import DatabaseParameterStatus, DatabaseParameterPragma
|
1948
1965
|
|
1949
1966
|
# Build.
|
1950
1967
|
|
1951
1968
|
## SQLite.
|
1952
1969
|
if self.backend == 'sqlite':
|
1953
|
-
dbp =
|
1970
|
+
dbp = DatabaseParameterPragma(self)
|
1954
1971
|
|
1955
1972
|
## Other.
|
1956
1973
|
else:
|
1957
|
-
dbp =
|
1974
|
+
dbp = DatabaseParameterStatus(self, False)
|
1958
1975
|
|
1959
1976
|
return dbp
|
1960
1977
|
|
@@ -1962,7 +1979,7 @@ class Database(BaseDatabase):
|
|
1962
1979
|
@property
|
1963
1980
|
def global_status(self):
|
1964
1981
|
"""
|
1965
|
-
Build
|
1982
|
+
Build `DatabaseParameterStatus` or `DatabaseParameterPragma` instance.
|
1966
1983
|
|
1967
1984
|
Returns
|
1968
1985
|
-------
|
@@ -1970,17 +1987,17 @@ class Database(BaseDatabase):
|
|
1970
1987
|
"""
|
1971
1988
|
|
1972
1989
|
# Import.
|
1973
|
-
from .rparam import
|
1990
|
+
from .rparam import DatabaseParameterStatus, DatabaseParameterPragma
|
1974
1991
|
|
1975
1992
|
# Build.
|
1976
1993
|
|
1977
1994
|
## SQLite.
|
1978
1995
|
if self.backend == 'sqlite':
|
1979
|
-
dbp =
|
1996
|
+
dbp = DatabaseParameterPragma(self)
|
1980
1997
|
|
1981
1998
|
## Other.
|
1982
1999
|
else:
|
1983
|
-
dbp =
|
2000
|
+
dbp = DatabaseParameterStatus(self, True)
|
1984
2001
|
|
1985
2002
|
return dbp
|
1986
2003
|
|
@@ -1988,7 +2005,7 @@ class Database(BaseDatabase):
|
|
1988
2005
|
@property
|
1989
2006
|
def variables(self):
|
1990
2007
|
"""
|
1991
|
-
Build instance
|
2008
|
+
Build `DatabaseParameterVariable` or `DatabaseParameterPragma` instance.
|
1992
2009
|
|
1993
2010
|
Returns
|
1994
2011
|
-------
|
@@ -1996,17 +2013,17 @@ class Database(BaseDatabase):
|
|
1996
2013
|
"""
|
1997
2014
|
|
1998
2015
|
# Import.
|
1999
|
-
from .rparam import
|
2016
|
+
from .rparam import DatabaseParameterVariable, DatabaseParameterPragma
|
2000
2017
|
|
2001
2018
|
# Build.
|
2002
2019
|
|
2003
2020
|
## SQLite.
|
2004
2021
|
if self.backend == 'sqlite':
|
2005
|
-
dbp =
|
2022
|
+
dbp = DatabaseParameterPragma(self)
|
2006
2023
|
|
2007
2024
|
## Other.
|
2008
2025
|
else:
|
2009
|
-
dbp =
|
2026
|
+
dbp = DatabaseParameterVariable(self, False)
|
2010
2027
|
|
2011
2028
|
return dbp
|
2012
2029
|
|
@@ -2022,17 +2039,17 @@ class Database(BaseDatabase):
|
|
2022
2039
|
"""
|
2023
2040
|
|
2024
2041
|
# Import.
|
2025
|
-
from .rparam import
|
2042
|
+
from .rparam import DatabaseParameterVariable, DatabaseParameterPragma
|
2026
2043
|
|
2027
2044
|
# Build.
|
2028
2045
|
|
2029
2046
|
## SQLite.
|
2030
2047
|
if self.backend == 'sqlite':
|
2031
|
-
dbp =
|
2048
|
+
dbp = DatabaseParameterPragma(self)
|
2032
2049
|
|
2033
2050
|
## Other.
|
2034
2051
|
else:
|
2035
|
-
dbp =
|
2052
|
+
dbp = DatabaseParameterVariable(self, True)
|
2036
2053
|
|
2037
2054
|
return dbp
|
2038
2055
|
|
reydb/rexec.py
CHANGED
@@ -13,17 +13,17 @@ from typing import Any, Self
|
|
13
13
|
from reykit.rbase import throw
|
14
14
|
from reykit.rtable import TableData
|
15
15
|
|
16
|
-
from .rbase import
|
17
|
-
from .rconn import
|
16
|
+
from .rbase import DatabaseBase
|
17
|
+
from .rconn import DatabaseConnection
|
18
18
|
from .rdb import Database, Result
|
19
19
|
|
20
20
|
|
21
21
|
__all__ = (
|
22
|
-
'
|
22
|
+
'DatabaseExecute',
|
23
23
|
)
|
24
24
|
|
25
25
|
|
26
|
-
class
|
26
|
+
class DatabaseExecute(DatabaseBase):
|
27
27
|
"""
|
28
28
|
Database execute type.
|
29
29
|
|
@@ -33,45 +33,45 @@ class DBExecute(BaseDatabase):
|
|
33
33
|
>>> field = ['id', 'value']
|
34
34
|
>>> where = '`id` = ids'
|
35
35
|
>>> ids = (1, 2)
|
36
|
-
>>> result =
|
36
|
+
>>> result = DatabaseExecute.database.table(field, where, ids=ids)
|
37
37
|
|
38
38
|
Insert.
|
39
39
|
>>> data = [{'id': 1}, {'id': 2}]
|
40
40
|
>>> duplicate = 'ignore'
|
41
|
-
>>> result =
|
42
|
-
>>> result =
|
43
|
-
>>> result =
|
41
|
+
>>> result = DatabaseExecute.database.table + data
|
42
|
+
>>> result = DatabaseExecute.database.table + (data, duplicate)
|
43
|
+
>>> result = DatabaseExecute.database.table + {'data': data, 'duplicate': duplicate}
|
44
44
|
|
45
45
|
Update.
|
46
46
|
>>> data = [{'name': 'a', 'id': 1}, {'name': 'b', 'id': 2}]
|
47
47
|
>>> where_fields = 'id'
|
48
|
-
>>> result =
|
49
|
-
>>> result =
|
50
|
-
>>> result =
|
48
|
+
>>> result = DatabaseExecute.database.table & data
|
49
|
+
>>> result = DatabaseExecute.database.table & (data, where_fields)
|
50
|
+
>>> result = DatabaseExecute.database.table & {'data': data, 'where_fields': where_fields}
|
51
51
|
|
52
52
|
Delete.
|
53
53
|
>>> where = '`id` IN (1, 2)'
|
54
54
|
>>> report = True
|
55
|
-
>>> result =
|
56
|
-
>>> result =
|
57
|
-
>>> result =
|
55
|
+
>>> result = DatabaseExecute.database.table - where
|
56
|
+
>>> result = DatabaseExecute.database.table - (where, report)
|
57
|
+
>>> result = DatabaseExecute.database.table - {'where': where, 'report': report}
|
58
58
|
|
59
59
|
Copy.
|
60
60
|
>>> where = '`id` IN (1, 2)'
|
61
61
|
>>> limit = 1
|
62
|
-
>>> result =
|
63
|
-
>>> result =
|
64
|
-
>>> result =
|
62
|
+
>>> result = DatabaseExecute.database.table * where
|
63
|
+
>>> result = DatabaseExecute.database.table * (where, limit)
|
64
|
+
>>> result = DatabaseExecute.database.table * {'where': where, 'limit': limit}
|
65
65
|
|
66
66
|
Exist.
|
67
67
|
>>> where = '`id` IN (1, 2)'
|
68
68
|
>>> report = True
|
69
|
-
>>> result = where in
|
70
|
-
>>> result = (where, report) in
|
71
|
-
>>> result = {'where': where, 'report': report} in
|
69
|
+
>>> result = where in DatabaseExecute.database.table
|
70
|
+
>>> result = (where, report) in DatabaseExecute.database.table
|
71
|
+
>>> result = {'where': where, 'report': report} in DatabaseExecute.database.table
|
72
72
|
|
73
73
|
Count.
|
74
|
-
>>> result = len(
|
74
|
+
>>> result = len(DatabaseExecute.database.table)
|
75
75
|
|
76
76
|
Default database.
|
77
77
|
>>> engine = Database(**server, database)
|
@@ -79,13 +79,13 @@ class DBExecute(BaseDatabase):
|
|
79
79
|
"""
|
80
80
|
|
81
81
|
|
82
|
-
def __init__(self, rdatabase: Database |
|
82
|
+
def __init__(self, rdatabase: Database | DatabaseConnection) -> None:
|
83
83
|
"""
|
84
84
|
Build instance attributes.
|
85
85
|
|
86
86
|
Parameters
|
87
87
|
----------
|
88
|
-
rdatabase : Database or
|
88
|
+
rdatabase : Database or DatabaseConnection instance.
|
89
89
|
"""
|
90
90
|
|
91
91
|
# Set parameter.
|