-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathpeewee.pyi
More file actions
1925 lines (1750 loc) · 66 KB
/
peewee.pyi
File metadata and controls
1925 lines (1750 loc) · 66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import itertools
import logging
import threading
from _typeshed import Incomplete, SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Iterable, Iterator
from datetime import datetime
from decimal import Decimal
from types import TracebackType
from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeVar, overload
from typing_extensions import Self
from uuid import UUID
class NullHandler(logging.Handler):
def emit(self, record) -> None: ...
text_type = str
bytes_type = bytes
buffer_type = memoryview
basestring = str
long = int
izip_longest = itertools.zip_longest
_T = TypeVar("_T")
_VT = TypeVar("_VT")
_F = TypeVar("_F", bound=Callable[..., Any])
class attrdict(dict[str, _VT]):
def __getattr__(self, attr: str) -> _VT: ...
def __setattr__(self, attr: str, value: _VT) -> None: ...
# calls dict.update()
def __iadd__(self, rhs: SupportsKeysAndGetItem[str, _VT] | Iterable[tuple[str, _VT]]) -> Self: ...
def __add__(self, rhs: SupportsKeysAndGetItem[str, _VT] | Iterable[tuple[str, _VT]]) -> attrdict[_VT]: ...
OP: attrdict[str]
DJANGO_MAP: attrdict[Incomplete]
JOIN: attrdict[str]
ROW: attrdict[int]
PREFETCH_TYPE: attrdict[int]
SCOPE_NORMAL: Final = 1
SCOPE_SOURCE: Final = 2
SCOPE_VALUES: Final = 4
SCOPE_CTE: Final = 8
SCOPE_COLUMN: Final = 16
CSQ_PARENTHESES_NEVER: Final = 0
CSQ_PARENTHESES_ALWAYS: Final = 1
CSQ_PARENTHESES_UNNESTED: Final = 2
def chunked(it, n) -> Generator[Incomplete, None, None]: ...
class _callable_context_manager:
def __call__(self, fn): ...
class Proxy:
__slots__ = ("obj", "_callbacks")
def __init__(self) -> None: ...
obj: Incomplete
def initialize(self, obj) -> None: ...
def attach_callback(self, callback): ...
def passthrough(method): ...
__enter__: Incomplete
__exit__: Incomplete
def __getattr__(self, attr: str): ...
def __setattr__(self, attr: str, value) -> None: ...
class DatabaseProxy(Proxy):
__slots__ = ("obj", "_callbacks", "_Model")
def connection_context(self) -> ConnectionContext: ...
def atomic(self, *args, **kwargs) -> _atomic: ...
def manual_commit(self) -> _manual: ...
def transaction(self, *args, **kwargs) -> _transaction: ...
def savepoint(self) -> _savepoint: ...
@property
def Model(self) -> type[Model]: ...
class ModelDescriptor: ...
class AliasManager:
__slots__ = ("_counter", "_current_index", "_mapping")
def __init__(self) -> None: ...
@property
def mapping(self): ...
def add(self, source): ...
def get(self, source, any_depth: bool = False): ...
def __getitem__(self, source): ...
def __setitem__(self, source, alias) -> None: ...
def push(self) -> None: ...
def pop(self) -> None: ...
class State:
def __new__(cls, scope=1, parentheses: bool = False, **kwargs) -> Self: ...
def __call__(self, scope=None, parentheses=None, **kwargs) -> State: ...
def __getattr__(self, attr_name: str): ...
class Context:
__slots__ = ("stack", "_sql", "_values", "alias_manager", "state")
stack: list[Incomplete]
alias_manager: AliasManager
state: State
def __init__(self, **settings) -> None: ...
def as_new(self) -> Context: ...
def column_sort_key(self, item): ...
@property
def scope(self): ...
@property
def parentheses(self): ...
@property
def subquery(self): ...
def __call__(self, **overrides) -> Self: ...
scope_normal: Incomplete
scope_source: Incomplete
scope_values: Incomplete
scope_cte: Incomplete
scope_column: Incomplete
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def push_alias(self) -> Generator[None]: ...
def sql(self, obj): ...
def literal(self, keyword) -> Self: ...
def value(self, value, converter=None, add_param: bool = True): ...
def __sql__(self, ctx): ...
def parse(self, node): ...
def query(self) -> tuple[str, list[Incomplete]]: ...
class Node:
__isabstractmethod__: bool
def clone(self) -> Self: ...
def __sql__(self, ctx): ...
@staticmethod
def copy(method): ...
def coerce(self, _coerce: bool = True) -> Self: ...
def is_alias(self) -> bool: ...
def unwrap(self) -> Self: ...
class ColumnFactory:
__slots__ = ("node",)
node: Node
def __init__(self, node: Node) -> None: ...
def __getattr__(self, attr: str) -> Column: ...
__getitem__ = __getattr__
class _DynamicColumn:
__slots__ = ()
def __get__(self, instance, instance_type=None): ...
class _ExplicitColumn:
__slots__ = ()
def __get__(self, instance, instance_type=None) -> Self: ...
class Star(Node):
def __init__(self, source) -> None: ...
def __sql__(self, ctx): ...
class Source(Node):
c: Incomplete
def __init__(self, alias=None) -> None: ...
def alias(self, name) -> Self: ...
def select(self, *columns) -> Select: ...
@property
def __star__(self) -> Star: ...
def join(self, dest, join_type="INNER JOIN", on=None) -> Join: ...
def left_outer_join(self, dest, on=None) -> Join: ...
def cte(self, name, recursive: bool = False, columns=None, materialized=None) -> CTE: ...
def get_sort_key(self, ctx) -> tuple[Incomplete, ...]: ...
def apply_alias(self, ctx): ...
def apply_column(self, ctx): ...
class _HashableSource:
def __init__(self, *args, **kwargs) -> None: ...
def alias(self, name) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other) -> Expression | bool: ... # type: ignore[override]
def __ne__(self, other) -> Expression | bool: ... # type: ignore[override]
__lt__: Callable[[Self, Any], Expression]
__le__: Callable[[Self, Any], Expression]
__gt__: Callable[[Self, Any], Expression]
__ge__: Callable[[Self, Any], Expression]
class BaseTable(Source):
def __and__(self, other) -> Join: ...
def __add__(self, other) -> Join: ...
def __sub__(self, other) -> Join: ...
def __or__(self, other) -> Join: ...
def __mul__(self, other) -> Join: ...
def __rand__(self, other) -> Join: ...
def __radd__(self, other) -> Join: ...
def __rsub__(self, other) -> Join: ...
def __ror__(self, other) -> Join: ...
def __rmul__(self, other) -> Join: ...
class _BoundTableContext(_callable_context_manager):
table: Incomplete
database: Incomplete
def __init__(self, table, database) -> None: ...
def __enter__(self): ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
class Table(_HashableSource, BaseTable): # type: ignore[misc]
__name__: Incomplete
c: Incomplete
primary_key: Incomplete
def __init__(
self, name, columns=None, primary_key=None, schema: str | None = None, alias=None, _model=None, _database=None
) -> None: ...
def clone(self) -> Table: ...
def bind(self, database=None) -> Self: ...
def bind_ctx(self, database=None) -> _BoundTableContext: ...
def select(self, *columns) -> Select: ...
def insert(self, insert=None, columns=None, **kwargs) -> Insert: ...
def replace(self, insert=None, columns=None, **kwargs): ...
def update(self, update=None, **kwargs) -> Update: ...
def delete(self) -> Delete: ...
def __sql__(self, ctx): ...
class Join(BaseTable):
lhs: Incomplete
rhs: Incomplete
join_type: Incomplete
def __init__(self, lhs, rhs, join_type="INNER JOIN", on=None, alias=None) -> None: ...
def on(self, predicate) -> Self: ...
def __sql__(self, ctx): ...
class ValuesList(_HashableSource, BaseTable): # type: ignore[misc]
def __init__(self, values, columns=None, alias=None) -> None: ...
def columns(self, *names) -> Self: ...
def __sql__(self, ctx): ...
class CTE(_HashableSource, Source): # type: ignore[misc]
def __init__(self, name, query, recursive: bool = False, columns=None, materialized=None) -> None: ...
def select_from(self, *columns): ...
def union_all(self, rhs) -> CTE: ...
__add__ = union_all
def union(self, rhs) -> CTE: ...
__or__ = union
def __sql__(self, ctx): ...
class ColumnBase(Node):
def converter(self, converter=None) -> Self: ...
def alias(self, alias): ...
def unalias(self) -> Self: ...
def bind_to(self, dest) -> BindTo: ...
def cast(self, as_type) -> Cast: ...
def asc(self, collation=None, nulls=None) -> Ordering: ...
__pos__ = asc
def desc(self, collation=None, nulls=None) -> Ordering: ...
__neg__ = desc
def __invert__(self): ...
__and__: Incomplete
__or__: Incomplete
def __add__(self, rhs: Any) -> Expression: ...
__sub__: Incomplete
__mul__: ClassVar[Callable[[Self, Any], Expression]]
__div__: ClassVar[Callable[[Self, Any], Expression]]
__truediv__: ClassVar[Callable[[Self, Any], Expression]]
__xor__: ClassVar[Callable[[Self, Any], Expression]]
def __radd__(self, rhs: Any) -> Expression: ...
__rsub__: ClassVar[Callable[[Self, Any], Expression]]
__rmul__: ClassVar[Callable[[Self, Any], Expression]]
__rdiv__: ClassVar[Callable[[Self, Any], Expression]]
__rtruediv__: ClassVar[Callable[[Self, Any], Expression]]
__rand__: ClassVar[Callable[[Self, Any], Expression]]
__ror__: ClassVar[Callable[[Self, Any], Expression]]
__rxor__: ClassVar[Callable[[Self, Any], Expression]]
def __eq__(self, rhs) -> Expression: ... # type: ignore[override]
def __ne__(self, rhs) -> Expression: ... # type: ignore[override]
__lt__: ClassVar[Callable[[Self, Any], Expression]]
__le__: ClassVar[Callable[[Self, Any], Expression]]
__gt__: ClassVar[Callable[[Self, Any], Expression]]
__ge__: ClassVar[Callable[[Self, Any], Expression]]
__lshift__: ClassVar[Callable[[Self, Any], Expression]]
__rshift__: ClassVar[Callable[[Self, Any], Expression]]
__mod__: ClassVar[Callable[[Self, Any], Expression]]
__pow__: ClassVar[Callable[[Self, Any], Expression]]
like: ClassVar[Callable[[Self, Any], Expression]]
ilike: ClassVar[Callable[[Self, Any], Expression]]
bin_and: ClassVar[Callable[[Self, Any], Expression]]
bin_or: ClassVar[Callable[[Self, Any], Expression]]
in_: ClassVar[Callable[[Self, Any], Expression]]
not_in: ClassVar[Callable[[Self, Any], Expression]]
regexp: ClassVar[Callable[[Self, Any], Expression]]
iregexp: ClassVar[Callable[[Self, Any], Expression]]
def is_null(self, is_null: bool = True) -> Expression: ...
def contains(self, rhs) -> Expression: ...
def startswith(self, rhs) -> Expression: ...
def endswith(self, rhs) -> Expression: ...
def between(self, lo, hi) -> Expression: ...
def concat(self, rhs) -> StringExpression: ...
def __getitem__(self, item): ...
__iter__: Incomplete
def distinct(self) -> NodeList: ...
def collate(self, collation) -> NodeList: ...
def get_sort_key(self, ctx) -> tuple[Incomplete, ...]: ...
class Column(ColumnBase):
source: Incomplete
name: Incomplete
def __init__(self, source, name) -> None: ...
def get_sort_key(self, ctx) -> tuple[Incomplete, ...]: ...
def __hash__(self) -> int: ...
def __sql__(self, ctx): ...
class WrappedNode(ColumnBase):
node: Incomplete
def __init__(self, node) -> None: ...
def is_alias(self) -> bool: ...
def unwrap(self): ...
class EntityFactory:
__slots__ = ("node",)
node: Incomplete
def __init__(self, node) -> None: ...
def __getattr__(self, attr: str) -> Entity: ...
class _DynamicEntity:
__slots__ = ()
def __get__(self, instance, instance_type=None): ...
class Alias(WrappedNode):
c: Incomplete
def __init__(self, node, alias) -> None: ...
def __hash__(self) -> int: ...
@property
def name(self): ...
@name.setter
def name(self, value) -> None: ...
def alias(self, alias=None): ...
def unalias(self): ...
def is_alias(self) -> bool: ...
def __sql__(self, ctx): ...
class BindTo(WrappedNode):
dest: Incomplete
def __init__(self, node, dest) -> None: ...
def __sql__(self, ctx): ...
class Negated(WrappedNode):
def __invert__(self): ...
def __sql__(self, ctx): ...
class BitwiseMixin:
def __and__(self, other): ...
def __or__(self, other): ...
def __sub__(self, other): ...
def __invert__(self) -> BitwiseNegated: ...
class BitwiseNegated(BitwiseMixin, WrappedNode):
def __invert__(self): ...
def __sql__(self, ctx): ...
class Value(ColumnBase):
value: Incomplete
converter: Incomplete
multi: Incomplete
values: list[Incomplete]
def __init__(self, value, converter=None, unpack: bool = True) -> None: ...
def __sql__(self, ctx): ...
class ValueLiterals(WrappedNode):
def __sql__(self, ctx): ...
def AsIs(value, converter=None) -> Value: ...
class Cast(WrappedNode):
def __init__(self, node, cast) -> None: ...
def __sql__(self, ctx): ...
class Ordering(WrappedNode):
direction: Incomplete
collation: Incomplete
nulls: Incomplete
def __init__(self, node, direction, collation=None, nulls=None) -> None: ...
def collate(self, collation=None) -> Ordering: ... # type: ignore[override]
def __sql__(self, ctx): ...
class Expression(ColumnBase):
lhs: Incomplete
op: Incomplete
rhs: Incomplete
flat: bool
def __init__(self, lhs, op, rhs, flat: bool = False) -> None: ...
def __sql__(self, ctx): ...
class StringExpression(Expression):
def __add__(self, rhs) -> StringExpression: ...
def __radd__(self, lhs) -> StringExpression: ...
class Entity(ColumnBase):
def __init__(self, *path) -> None: ...
def __getattr__(self, attr: str) -> Entity: ...
def get_sort_key(self, ctx) -> tuple[Incomplete, ...]: ...
def __hash__(self) -> int: ...
def __sql__(self, ctx): ...
class SQL(ColumnBase):
sql: Incomplete
params: Incomplete
def __init__(self, sql, params=None) -> None: ...
def __sql__(self, ctx): ...
def Check(constraint, name=None): ...
def Default(value) -> SQL: ...
class Function(ColumnBase):
no_coerce_functions: ClassVar[set[str]]
name: Incomplete
arguments: Incomplete
def __init__(self, name, arguments, coerce: bool = True, python_value=None) -> None: ...
def __getattr__(self, attr: str): ...
def filter(self, where=None) -> Self: ...
def order_by(self, *ordering) -> Self: ...
def python_value(self, func=None) -> Self: ...
def over(
self, partition_by=None, order_by=None, start=None, end=None, frame_type=None, window=None, exclude=None
) -> NodeList: ...
def __sql__(self, ctx): ...
fn: Incomplete
class Window(Node):
CURRENT_ROW: SQL
GROUP: SQL
TIES: SQL
NO_OTHERS: SQL
GROUPS: str
RANGE: str
ROWS: str
partition_by: Incomplete
order_by: Incomplete
start: Incomplete
end: Incomplete
frame_type: Incomplete
def __init__(
self,
partition_by=None,
order_by=None,
start=None,
end=None,
frame_type=None,
extends=None,
exclude=None,
alias=None,
_inline: bool = False,
) -> None: ...
def alias(self, alias=None) -> Self: ...
def as_range(self) -> Self: ...
def as_rows(self) -> Self: ...
def as_groups(self) -> Self: ...
def extends(self, window=None) -> Self: ...
def exclude(self, frame_exclusion=None) -> Self: ...
@staticmethod
def following(value=None) -> SQL: ...
@staticmethod
def preceding(value=None) -> SQL: ...
def __sql__(self, ctx): ...
class WindowAlias(Node):
window: Incomplete
def __init__(self, window) -> None: ...
def alias(self, window_alias) -> Self: ...
def __sql__(self, ctx): ...
class ForUpdate(Node):
def __init__(self, expr, of=None, nowait=None) -> None: ...
def __sql__(self, ctx): ...
class Case(ColumnBase):
predicate: Incomplete
expression_tuples: Incomplete
default: Incomplete | None
def __init__(self, predicate, expression_tuples, default=None) -> None: ...
def __sql__(self, ctx): ...
class NodeList(ColumnBase):
nodes: Incomplete
glue: Incomplete
parens: Incomplete
def __init__(self, nodes, glue: str = " ", parens: bool = False) -> None: ...
def __sql__(self, ctx): ...
class _Namespace(Node):
__slots__ = ("_name",)
def __init__(self, name) -> None: ...
def __getattr__(self, attr: str) -> NamespaceAttribute: ...
__getitem__ = __getattr__
class NamespaceAttribute(ColumnBase):
def __init__(self, namespace, attribute) -> None: ...
def __sql__(self, ctx): ...
EXCLUDED: Incomplete
class DQ(ColumnBase):
query: Incomplete
def __init__(self, **query) -> None: ...
def __invert__(self) -> Self: ... # type: ignore[override]
def clone(self) -> DQ: ...
Tuple: Incomplete
class QualifiedNames(WrappedNode):
def __sql__(self, ctx): ...
class OnConflict(Node):
def __init__(
self,
action=None,
update=None,
preserve=None,
where=None,
conflict_target=None,
conflict_where=None,
conflict_constraint=None,
) -> None: ...
def get_conflict_statement(self, ctx, query): ...
def get_conflict_update(self, ctx, query): ...
def preserve(self, *columns) -> Self: ...
def update(self, _data=None, **kwargs) -> Self: ...
def where(self, *expressions) -> Self: ...
def conflict_target(self, *constraints) -> Self: ...
def conflict_where(self, *expressions) -> Self: ...
def conflict_constraint(self, constraint) -> Self: ...
class BaseQuery(Node):
default_row_type: Incomplete
def __init__(self, _database=None, **kwargs) -> None: ...
def bind(self, database=None) -> Self: ...
def clone(self) -> Self: ...
def dicts(self, as_dict: bool = True) -> Self: ...
def tuples(self, as_tuple: bool = True) -> Self: ...
def namedtuples(self, as_namedtuple: bool = True) -> Self: ...
def objects(self, constructor=None) -> Self: ...
def __sql__(self, ctx) -> None: ...
def sql(self): ...
def execute(self, database=None): ...
def iterator(self, database=None): ...
def __iter__(self): ...
def __getitem__(self, value): ...
def __len__(self) -> int: ...
class RawQuery(BaseQuery):
def __init__(self, sql=None, params=None, **kwargs) -> None: ...
def __sql__(self, ctx): ...
class Query(BaseQuery):
def __init__(self, where=None, order_by=None, limit=None, offset=None, **kwargs) -> None: ...
def with_cte(self, *cte_list) -> Self: ...
def where(self, *expressions) -> Self: ...
def orwhere(self, *expressions) -> Self: ...
def order_by(self, *values) -> Self: ...
def order_by_extend(self, *values) -> Self: ...
def limit(self, value=None) -> Self: ...
def offset(self, value=None) -> Self: ...
def paginate(self, page, paginate_by: int = 20) -> Self: ...
def __sql__(self, ctx): ...
class SelectQuery(Query):
def union_all(self, other) -> CompoundSelectQuery: ...
def __add__(self, other) -> CompoundSelectQuery: ...
def union(self, other) -> CompoundSelectQuery: ...
def __or__(self, other) -> CompoundSelectQuery: ...
def intersect(self, other) -> CompoundSelectQuery: ...
def __and__(self, other) -> CompoundSelectQuery: ...
def except_(self, other) -> CompoundSelectQuery: ...
def __sub__(self, other) -> CompoundSelectQuery: ...
def __radd__(self, other) -> CompoundSelectQuery: ...
def __ror__(self, other) -> CompoundSelectQuery: ...
def __rand__(self, other) -> CompoundSelectQuery: ...
def __rsub__(self, other) -> CompoundSelectQuery: ...
def select_from(self, *columns) -> Select: ...
class SelectBase(_HashableSource, Source, SelectQuery): # type: ignore[misc]
def peek(self, database=None, n: int = 1): ...
def first(self, database=None, n: int = 1): ...
def scalar(self, database=None, as_tuple: bool = False, as_dict: bool = False): ...
def scalars(self, database=None) -> Generator[Incomplete, None, None]: ...
def count(self, database=None, clear_limit: bool = False): ...
def exists(self, database=None) -> bool: ...
def get(self, database=None): ...
class CompoundSelectQuery(SelectBase):
lhs: Incomplete
op: Incomplete
rhs: Incomplete
def __init__(self, lhs, op, rhs) -> None: ...
def exists(self, database=None) -> bool: ...
def __sql__(self, ctx): ...
class Select(SelectBase):
def __init__(
self,
from_list=None,
columns=None,
group_by=None,
having=None,
distinct=None,
windows=None,
for_update=None,
for_update_of=None,
nowait=None,
lateral=None,
**kwargs,
) -> None: ...
def clone(self) -> Self: ...
def columns(self, *columns, **kwargs) -> Self: ...
select = columns
def select_extend(self, *columns) -> Self: ...
@property
def selected_columns(self): ...
@selected_columns.setter
def selected_columns(self, value) -> None: ...
def from_(self, *sources) -> Self: ...
def join(self, dest, join_type="INNER JOIN", on=None) -> Self: ... # type: ignore[override]
def left_outer_join(self, dest, on=None) -> Self: ... # type: ignore[override]
def group_by(self, *columns) -> Self: ...
def group_by_extend(self, *values) -> Self: ...
def having(self, *expressions) -> Self: ...
def distinct(self, *columns) -> Self: ...
def window(self, *windows) -> Self: ...
def for_update(self, for_update: bool = True, of=None, nowait=None) -> Self: ...
def lateral(self, lateral: bool = True) -> Self: ...
def __sql_selection__(self, ctx, is_subquery: bool = False): ...
def __sql__(self, ctx): ...
class _WriteQuery(Query):
table: Incomplete
def __init__(self, table, returning=None, **kwargs) -> None: ...
def cte(self, name, recursive: bool = False, columns=None, materialized=None) -> CTE: ...
def returning(self, *returning) -> Self: ...
def apply_returning(self, ctx): ...
def execute_returning(self, database): ...
def handle_result(self, database, cursor): ...
def __sql__(self, ctx): ...
class Update(_WriteQuery):
def __init__(self, table, update=None, **kwargs) -> None: ...
def from_(self, *sources) -> Self: ...
def __sql__(self, ctx): ...
class Insert(_WriteQuery):
SIMPLE: int
QUERY: int
MULTI: int
class DefaultValuesException(Exception): ...
def __init__(self, table, insert=None, columns=None, on_conflict=None, **kwargs) -> None: ...
def where(self, *expressions): ...
def as_rowcount(self, _as_rowcount: bool = True) -> Self: ...
def on_conflict_ignore(self, ignore: bool = True) -> Self: ...
def on_conflict_replace(self, replace: bool = True) -> Self: ...
def on_conflict(self, *args, **kwargs) -> Self: ...
def get_default_data(self): ...
def get_default_columns(self) -> list[Incomplete] | None: ...
def __sql__(self, ctx): ...
def handle_result(self, database, cursor): ...
class Delete(_WriteQuery):
def __sql__(self, ctx): ...
class Index(Node):
def __init__(
self, name, table, expressions, unique: bool = False, safe: bool = False, where=None, using=None, nulls_distinct=None
) -> None: ...
def safe(self, _safe: bool = True) -> Self: ...
def where(self, *expressions) -> Self: ...
def using(self, _using=None) -> Self: ...
def nulls_distinct(self, nulls_distinct=None) -> Self: ...
def __sql__(self, ctx): ...
class ModelIndex(Index):
def __init__(
self, model, fields, unique: bool = False, safe: bool = True, where=None, using=None, name=None, nulls_distinct=None
) -> None: ...
class PeeweeException(Exception):
def __init__(self, *args) -> None: ...
class ImproperlyConfigured(PeeweeException): ...
class DatabaseError(PeeweeException): ...
class DataError(DatabaseError): ...
class IntegrityError(DatabaseError): ...
class InterfaceError(PeeweeException): ...
class InternalError(DatabaseError): ...
class NotSupportedError(DatabaseError): ...
class OperationalError(DatabaseError): ...
class ProgrammingError(DatabaseError): ...
class ExceptionWrapper:
__slots__ = ("exceptions",)
exceptions: Incomplete
def __init__(self, exceptions) -> None: ...
def __enter__(self) -> None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...
class IndexMetadata(NamedTuple):
name: Incomplete
sql: Incomplete
columns: Incomplete
unique: Incomplete
table: Incomplete
class ColumnMetadata(NamedTuple):
name: Incomplete
data_type: Incomplete
null: Incomplete
primary_key: Incomplete
table: Incomplete
default: Incomplete
class ForeignKeyMetadata(NamedTuple):
column: Incomplete
dest_table: Incomplete
dest_column: Incomplete
table: Incomplete
class ViewMetadata(NamedTuple):
name: Incomplete
sql: Incomplete
class _ConnectionState:
def __init__(self, **kwargs) -> None: ...
closed: bool
conn: Incomplete
ctx: Incomplete
transactions: Incomplete
def reset(self) -> None: ...
def set_connection(self, conn) -> None: ...
class _ConnectionLocal(_ConnectionState, threading.local): ...
class _NoopLock:
__slots__ = ()
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
class ConnectionContext(_callable_context_manager):
__slots__ = ("db",)
db: Incomplete
def __init__(self, db) -> None: ...
def __enter__(self) -> None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
class Database(_callable_context_manager):
context_class: Incomplete
field_types: Incomplete
operations: Incomplete
param: str
quote: str
server_version: Incomplete
commit_select: bool
compound_select_parentheses: Incomplete
for_update: bool
index_schema_prefix: bool
index_using_precedes_table: bool
limit_max: Incomplete
nulls_ordering: bool
returning_clause: bool
safe_create_index: bool
safe_drop_index: bool
sequences: bool
truncate_table: bool
autoconnect: Incomplete
thread_safe: Incomplete
connect_params: Incomplete
def __init__(
self,
database,
thread_safe: bool = True,
autorollback: bool = False,
field_types=None,
operations=None,
autocommit=None,
autoconnect: bool = True,
**kwargs,
) -> None: ...
database: Incomplete
deferred: Incomplete
def init(self, database, **kwargs) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def connection_context(self) -> ConnectionContext: ...
def connect(self, reuse_if_open: bool = False) -> bool: ...
def close(self) -> bool: ...
def is_closed(self) -> bool: ...
def is_connection_usable(self) -> bool: ...
def connection(self): ...
def cursor(self, named_cursor=None): ...
def execute_sql(self, sql, params=None): ...
def execute(self, query, **context_options): ...
def get_context_options(self) -> dict[str, Incomplete]: ...
def get_sql_context(self, **context_options) -> context_class: ...
def conflict_statement(self, on_conflict, query): ...
def conflict_update(self, on_conflict, query): ...
def last_insert_id(self, cursor, query_type=None): ...
def rows_affected(self, cursor): ...
def default_values_insert(self, ctx): ...
def session_start(self) -> _transaction: ...
def session_commit(self) -> bool: ...
def session_rollback(self) -> bool: ...
def in_transaction(self) -> bool: ...
def push_transaction(self, transaction) -> None: ...
def pop_transaction(self): ...
def transaction_depth(self) -> int: ...
def top_transaction(self): ...
def atomic(self, *args, **kwargs) -> _atomic: ...
def manual_commit(self) -> _manual: ...
def transaction(self, *args, **kwargs) -> _transaction: ...
def savepoint(self) -> _savepoint: ...
def begin(self) -> None: ...
def commit(self) -> None: ...
def rollback(self) -> None: ...
def batch_commit(self, it, n) -> Generator[Incomplete, None, None]: ...
def table_exists(self, table_name, schema: str | None = None) -> bool: ...
def get_tables(self, schema: str | None = None) -> list[str]: ...
def get_indexes(self, table, schema: str | None = None) -> list[IndexMetadata]: ...
def get_columns(self, table, schema: str | None = None) -> list[ColumnMetadata]: ...
def get_primary_keys(self, table, schema: str | None = None): ...
def get_foreign_keys(self, table, schema: str | None = None) -> list[ForeignKeyMetadata]: ...
def sequence_exists(self, seq) -> bool: ...
def create_tables(self, models: Iterable[type[Model]], **options) -> None: ...
def drop_tables(self, models: Iterable[type[Model]], **kwargs) -> None: ...
def extract_date(self, date_part, date_field): ...
def truncate_date(self, date_part, date_field): ...
def to_timestamp(self, date_field): ...
def from_timestamp(self, date_field): ...
def random(self): ...
def bind(self, models: Iterable[type[Model]], bind_refs: bool = True, bind_backrefs: bool = True) -> None: ...
def bind_ctx(
self, models: Iterable[type[Model]], bind_refs: bool = True, bind_backrefs: bool = True
) -> _BoundModelsContext: ...
def get_noop_select(self, ctx): ...
@property
def Model(self) -> type[Model]: ...
class SqliteDatabase(Database):
field_types: Incomplete
operations: Incomplete
index_schema_prefix: bool
limit_max: int
server_version: Incomplete
truncate_table: bool
nulls_ordering: bool
def __init__(
self, database, pragmas=None, regexp_function: bool = False, rank_functions: bool = False, *args, **kwargs
) -> None: ...
returning_clause: Incomplete
def init(self, database, pragmas=None, timeout: int = 5, returning_clause=None, **kwargs) -> None: ...
def pragma(self, key, value=..., permanent: bool = False, schema: str | None = None): ...
cache_size: Incomplete
foreign_keys: Incomplete
journal_mode: Incomplete
journal_size_limit: Incomplete
mmap_size: Incomplete
page_size: Incomplete
read_uncommitted: Incomplete
synchronous: Incomplete
wal_autocheckpoint: Incomplete
application_id: Incomplete
user_version: Incomplete
data_version: Incomplete
@property
def timeout(self): ...
@timeout.setter
def timeout(self, seconds) -> None: ...
def register_aggregate(self, klass, name=None, num_params: int = -1) -> None: ...
def aggregate(self, name=None, num_params: int = -1): ...
def register_collation(self, fn, name=None) -> None: ...
def collation(self, name=None): ...
def register_function(self, fn, name: str | None = None, num_params: int = -1, deterministic: bool | None = None) -> None: ...
def func(self, name: str | None = None, num_params: int = -1, deterministic: bool | None = None) -> Callable[[_F], _F]: ...
def register_window_function(self, klass, name=None, num_params: int = -1) -> None: ...
def window_function(self, name=None, num_params: int = -1): ...
def unregister_aggregate(self, name) -> None: ...
def unregister_collation(self, name) -> None: ...
def unregister_function(self, name) -> None: ...
def unregister_window_function(self, name) -> None: ...
def load_extension(self, extension) -> None: ...
def unload_extension(self, extension) -> None: ...
def attach(self, filename, name) -> bool: ...
def detach(self, name) -> bool: ...
def last_insert_id(self, cursor, query_type=None): ...
def rows_affected(self, cursor): ...
def begin(self, lock_type=None) -> None: ...
def get_tables(self, schema: str | None = None) -> list[str]: ...
def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ...
def get_indexes(self, table, schema: str | None = None) -> list[IndexMetadata]: ...
def get_columns(self, table, schema: str | None = None) -> list[ColumnMetadata]: ...
def get_primary_keys(self, table, schema: str | None = None) -> list[Incomplete]: ...
def get_foreign_keys(self, table, schema: str | None = None) -> list[ForeignKeyMetadata]: ...
def get_binary_type(self): ...
def conflict_statement(self, on_conflict, query) -> SQL | None: ...
def conflict_update(self, oc, query) -> SQL | NodeList | None: ...
def extract_date(self, date_part, date_field) -> Function: ...
def truncate_date(self, date_part, date_field) -> Function: ...
def to_timestamp(self, date_field) -> Cast: ...
def from_timestamp(self, date_field) -> Function: ...
class _BasePsycopgAdapter:
isolation_levels: dict[int, str]
isolation_levels_inv: dict[str, int]
def __init__(self) -> None: ...
@overload
def isolation_level_int(self, isolation_level: str) -> int: ...
@overload
def isolation_level_int(self, isolation_level: _T) -> _T: ...
@overload
def isolation_level_str(self, isolation_level: int) -> str: ...
@overload
def isolation_level_str(self, isolation_level: _T) -> _T: ...
class Psycopg2Adapter(_BasePsycopgAdapter):
json_type: Incomplete
jsonb_type: Incomplete
cast_json_case: bool
def __init__(self) -> None: ...
def check_driver(self) -> None: ...
def get_binary_type(self) -> type[Incomplete]: ...
def connect(self, db, **params): ...
def get_server_version(self, conn): ...
def is_connection_usable(self, conn) -> bool: ...
def is_connection_reusable(self, conn) -> bool: ...
def is_connection_closed(self, conn) -> bool: ...
def extract_date(self, date_part, date_field) -> Function: ...
class Psycopg3Adapter(_BasePsycopgAdapter):
json_type: Incomplete
jsonb_type: Incomplete
cast_json_case: bool
def __init__(self) -> None: ...
def check_driver(self) -> None: ...
def get_binary_type(self) -> type[Incomplete]: ...
def connect(self, db, **params): ...
def get_server_version(self, conn): ...
def is_connection_usable(self, conn) -> bool: ...
def is_connection_reusable(self, conn) -> bool: ...
def is_connection_closed(self, conn) -> bool: ...
def extract_date(self, date_part, date_field) -> Function: ...
class PostgresqlDatabase(Database):
field_types: Incomplete
operations: Incomplete
param: str
commit_select: bool
compound_select_parentheses: Incomplete
for_update: bool
nulls_ordering: bool
returning_clause: bool
safe_create_index: bool
sequences: bool
psycopg2_adapter: Incomplete
psycopg3_adapter: Incomplete
def init(
self,
database,
register_unicode: bool = True,
encoding=None,
isolation_level=None,
*,
prefer_psycopg3: bool = False,
**kwargs,
) -> None: ...
def is_connection_usable(self) -> bool: ...
def last_insert_id(self, cursor, query_type=None): ...
def rows_affected(self, cursor): ...
def begin(self, isolation_level: str | None = None) -> None: ...
def get_tables(self, schema: str | None = None) -> list[str]: ...
def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ...
def get_indexes(self, table, schema: str | None = None) -> list[IndexMetadata]: ...
def get_columns(self, table, schema: str | None = None) -> list[ColumnMetadata]: ...
def get_primary_keys(self, table, schema: str | None = None) -> list[Incomplete]: ...
def get_foreign_keys(self, table, schema: str | None = None) -> list[ForeignKeyMetadata]: ...
def sequence_exists(self, sequence) -> bool: ...
def get_binary_type(self) -> type[Incomplete]: ...
def conflict_statement(self, on_conflict, query) -> None: ...
def conflict_update(self, oc, query) -> NodeList: ...
def extract_date(self, date_part, date_field) -> Function: ...
def truncate_date(self, date_part, date_field) -> Function: ...
def to_timestamp(self, date_field) -> Function: ...
def from_timestamp(self, date_field) -> Function: ...
def get_noop_select(self, ctx): ...
def set_time_zone(self, timezone) -> None: ...
def set_isolation_level(self, isolation_level: int | str) -> None: ...
class MySQLDatabase(Database):
field_types: Incomplete
operations: Incomplete
param: str
quote: str
commit_select: bool