dataclassdb 0.1.0__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.
- dataclassdb/__init__.py +19 -0
- dataclassdb/builders/function_builder.py +407 -0
- dataclassdb/builders/list_utils.py +48 -0
- dataclassdb/builders/query_builder.py +158 -0
- dataclassdb/builders/statement_builder.py +635 -0
- dataclassdb/builders/string_builder.py +98 -0
- dataclassdb/constants.py +372 -0
- dataclassdb/dataclass_db.py +282 -0
- dataclassdb/dataclass_field_codec.py +216 -0
- dataclassdb/dataclass_sqlite_field.py +193 -0
- dataclassdb/dataclass_sqlite_table.py +152 -0
- dataclassdb/dataclass_types.py +22 -0
- dataclassdb/db_engine.py +126 -0
- dataclassdb/utils.py +74 -0
- dataclassdb-0.1.0.dist-info/METADATA +237 -0
- dataclassdb-0.1.0.dist-info/RECORD +19 -0
- dataclassdb-0.1.0.dist-info/WHEEL +5 -0
- dataclassdb-0.1.0.dist-info/licenses/LICENSE +21 -0
- dataclassdb-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
"""This script creates the getter and setter sql files from strenums."""
|
|
2
|
+
|
|
3
|
+
__all__ = ['StatementBuilder']
|
|
4
|
+
|
|
5
|
+
from typing import Self
|
|
6
|
+
|
|
7
|
+
from dataclassdb.builders.string_builder import StringBuilder
|
|
8
|
+
from dataclassdb.constants import SQL
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class StatementBuilder(StringBuilder):
|
|
12
|
+
# Generated from scripts/generate_builder_files.py
|
|
13
|
+
@property
|
|
14
|
+
def ABORT(self) -> Self:
|
|
15
|
+
return self.add(SQL.ABORT)
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def ACTION(self) -> Self:
|
|
19
|
+
return self.add(SQL.ACTION)
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def ADD(self) -> Self:
|
|
23
|
+
return self.add(SQL.ADD)
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def AFTER(self) -> Self:
|
|
27
|
+
return self.add(SQL.AFTER)
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def ALL(self) -> Self:
|
|
31
|
+
return self.add(SQL.ALL)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def ALTER(self) -> Self:
|
|
35
|
+
return self.add(SQL.ALTER)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def ALWAYS(self) -> Self:
|
|
39
|
+
return self.add(SQL.ALWAYS)
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def ANALYZE(self) -> Self:
|
|
43
|
+
return self.add(SQL.ANALYZE)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def AND(self) -> Self:
|
|
47
|
+
return self.add(SQL.AND)
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def AS(self) -> Self:
|
|
51
|
+
return self.add(SQL.AS)
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def ASC(self) -> Self:
|
|
55
|
+
return self.add(SQL.ASC)
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def ATTACH(self) -> Self:
|
|
59
|
+
return self.add(SQL.ATTACH)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def AUTOINCREMENT(self) -> Self:
|
|
63
|
+
return self.add(SQL.AUTOINCREMENT)
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def BEFORE(self) -> Self:
|
|
67
|
+
return self.add(SQL.BEFORE)
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def BEGIN(self) -> Self:
|
|
71
|
+
return self.add(SQL.BEGIN)
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def BETWEEN(self) -> Self:
|
|
75
|
+
return self.add(SQL.BETWEEN)
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def BY(self) -> Self:
|
|
79
|
+
return self.add(SQL.BY)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def CASCADE(self) -> Self:
|
|
83
|
+
return self.add(SQL.CASCADE)
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def CASE(self) -> Self:
|
|
87
|
+
return self.add(SQL.CASE)
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def CAST(self) -> Self:
|
|
91
|
+
return self.add(SQL.CAST)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def CHECK(self) -> Self:
|
|
95
|
+
return self.add(SQL.CHECK)
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def COLLATE(self) -> Self:
|
|
99
|
+
return self.add(SQL.COLLATE)
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def COLUMN(self) -> Self:
|
|
103
|
+
return self.add(SQL.COLUMN)
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def COMMIT(self) -> Self:
|
|
107
|
+
return self.add(SQL.COMMIT)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def CONFLICT(self) -> Self:
|
|
111
|
+
return self.add(SQL.CONFLICT)
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def CONSTRAINT(self) -> Self:
|
|
115
|
+
return self.add(SQL.CONSTRAINT)
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def CREATE(self) -> Self:
|
|
119
|
+
return self.add(SQL.CREATE)
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def CROSS(self) -> Self:
|
|
123
|
+
return self.add(SQL.CROSS)
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def CURRENT(self) -> Self:
|
|
127
|
+
return self.add(SQL.CURRENT)
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def CURRENT_DATE(self) -> Self:
|
|
131
|
+
return self.add(SQL.CURRENT_DATE)
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def CURRENT_TIME(self) -> Self:
|
|
135
|
+
return self.add(SQL.CURRENT_TIME)
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def CURRENT_TIMESTAMP(self) -> Self:
|
|
139
|
+
return self.add(SQL.CURRENT_TIMESTAMP)
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def DATABASE(self) -> Self:
|
|
143
|
+
return self.add(SQL.DATABASE)
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def DEFAULT(self) -> Self:
|
|
147
|
+
return self.add(SQL.DEFAULT)
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def DEFERRABLE(self) -> Self:
|
|
151
|
+
return self.add(SQL.DEFERRABLE)
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def DEFERRED(self) -> Self:
|
|
155
|
+
return self.add(SQL.DEFERRED)
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def DELETE(self) -> Self:
|
|
159
|
+
return self.add(SQL.DELETE)
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
def DESC(self) -> Self:
|
|
163
|
+
return self.add(SQL.DESC)
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def DETACH(self) -> Self:
|
|
167
|
+
return self.add(SQL.DETACH)
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def DISTINCT(self) -> Self:
|
|
171
|
+
return self.add(SQL.DISTINCT)
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def DO(self) -> Self:
|
|
175
|
+
return self.add(SQL.DO)
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def DROP(self) -> Self:
|
|
179
|
+
return self.add(SQL.DROP)
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def EACH(self) -> Self:
|
|
183
|
+
return self.add(SQL.EACH)
|
|
184
|
+
|
|
185
|
+
@property
|
|
186
|
+
def ELSE(self) -> Self:
|
|
187
|
+
return self.add(SQL.ELSE)
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def END(self) -> Self:
|
|
191
|
+
return self.add(SQL.END)
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def ESCAPE(self) -> Self:
|
|
195
|
+
return self.add(SQL.ESCAPE)
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
def EXCEPT(self) -> Self:
|
|
199
|
+
return self.add(SQL.EXCEPT)
|
|
200
|
+
|
|
201
|
+
@property
|
|
202
|
+
def EXCLUDE(self) -> Self:
|
|
203
|
+
return self.add(SQL.EXCLUDE)
|
|
204
|
+
|
|
205
|
+
@property
|
|
206
|
+
def EXCLUSIVE(self) -> Self:
|
|
207
|
+
return self.add(SQL.EXCLUSIVE)
|
|
208
|
+
|
|
209
|
+
@property
|
|
210
|
+
def EXISTS(self) -> Self:
|
|
211
|
+
return self.add(SQL.EXISTS)
|
|
212
|
+
|
|
213
|
+
@property
|
|
214
|
+
def EXPLAIN(self) -> Self:
|
|
215
|
+
return self.add(SQL.EXPLAIN)
|
|
216
|
+
|
|
217
|
+
@property
|
|
218
|
+
def FAIL(self) -> Self:
|
|
219
|
+
return self.add(SQL.FAIL)
|
|
220
|
+
|
|
221
|
+
@property
|
|
222
|
+
def FILTER(self) -> Self:
|
|
223
|
+
return self.add(SQL.FILTER)
|
|
224
|
+
|
|
225
|
+
@property
|
|
226
|
+
def FIRST(self) -> Self:
|
|
227
|
+
return self.add(SQL.FIRST)
|
|
228
|
+
|
|
229
|
+
@property
|
|
230
|
+
def FOLLOWING(self) -> Self:
|
|
231
|
+
return self.add(SQL.FOLLOWING)
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def FOR(self) -> Self:
|
|
235
|
+
return self.add(SQL.FOR)
|
|
236
|
+
|
|
237
|
+
@property
|
|
238
|
+
def FOREIGN(self) -> Self:
|
|
239
|
+
return self.add(SQL.FOREIGN)
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def FROM(self) -> Self:
|
|
243
|
+
return self.add(SQL.FROM)
|
|
244
|
+
|
|
245
|
+
@property
|
|
246
|
+
def FULL(self) -> Self:
|
|
247
|
+
return self.add(SQL.FULL)
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def GENERATED(self) -> Self:
|
|
251
|
+
return self.add(SQL.GENERATED)
|
|
252
|
+
|
|
253
|
+
@property
|
|
254
|
+
def GLOB(self) -> Self:
|
|
255
|
+
return self.add(SQL.GLOB)
|
|
256
|
+
|
|
257
|
+
@property
|
|
258
|
+
def GROUP(self) -> Self:
|
|
259
|
+
return self.add(SQL.GROUP)
|
|
260
|
+
|
|
261
|
+
@property
|
|
262
|
+
def GROUPS(self) -> Self:
|
|
263
|
+
return self.add(SQL.GROUPS)
|
|
264
|
+
|
|
265
|
+
@property
|
|
266
|
+
def HAVING(self) -> Self:
|
|
267
|
+
return self.add(SQL.HAVING)
|
|
268
|
+
|
|
269
|
+
@property
|
|
270
|
+
def IF(self) -> Self:
|
|
271
|
+
return self.add(SQL.IF)
|
|
272
|
+
|
|
273
|
+
@property
|
|
274
|
+
def IGNORE(self) -> Self:
|
|
275
|
+
return self.add(SQL.IGNORE)
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def IMMEDIATE(self) -> Self:
|
|
279
|
+
return self.add(SQL.IMMEDIATE)
|
|
280
|
+
|
|
281
|
+
@property
|
|
282
|
+
def IN(self) -> Self:
|
|
283
|
+
return self.add(SQL.IN)
|
|
284
|
+
|
|
285
|
+
@property
|
|
286
|
+
def INDEX(self) -> Self:
|
|
287
|
+
return self.add(SQL.INDEX)
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def INDEXED(self) -> Self:
|
|
291
|
+
return self.add(SQL.INDEXED)
|
|
292
|
+
|
|
293
|
+
@property
|
|
294
|
+
def INITIALLY(self) -> Self:
|
|
295
|
+
return self.add(SQL.INITIALLY)
|
|
296
|
+
|
|
297
|
+
@property
|
|
298
|
+
def INNER(self) -> Self:
|
|
299
|
+
return self.add(SQL.INNER)
|
|
300
|
+
|
|
301
|
+
@property
|
|
302
|
+
def INSERT(self) -> Self:
|
|
303
|
+
return self.add(SQL.INSERT)
|
|
304
|
+
|
|
305
|
+
@property
|
|
306
|
+
def INSTEAD(self) -> Self:
|
|
307
|
+
return self.add(SQL.INSTEAD)
|
|
308
|
+
|
|
309
|
+
@property
|
|
310
|
+
def INTERSECT(self) -> Self:
|
|
311
|
+
return self.add(SQL.INTERSECT)
|
|
312
|
+
|
|
313
|
+
@property
|
|
314
|
+
def INTO(self) -> Self:
|
|
315
|
+
return self.add(SQL.INTO)
|
|
316
|
+
|
|
317
|
+
@property
|
|
318
|
+
def IS(self) -> Self:
|
|
319
|
+
return self.add(SQL.IS)
|
|
320
|
+
|
|
321
|
+
@property
|
|
322
|
+
def ISNULL(self) -> Self:
|
|
323
|
+
return self.add(SQL.ISNULL)
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def JOIN(self) -> Self:
|
|
327
|
+
return self.add(SQL.JOIN)
|
|
328
|
+
|
|
329
|
+
@property
|
|
330
|
+
def KEY(self) -> Self:
|
|
331
|
+
return self.add(SQL.KEY)
|
|
332
|
+
|
|
333
|
+
@property
|
|
334
|
+
def LAST(self) -> Self:
|
|
335
|
+
return self.add(SQL.LAST)
|
|
336
|
+
|
|
337
|
+
@property
|
|
338
|
+
def LEFT(self) -> Self:
|
|
339
|
+
return self.add(SQL.LEFT)
|
|
340
|
+
|
|
341
|
+
@property
|
|
342
|
+
def LIKE(self) -> Self:
|
|
343
|
+
return self.add(SQL.LIKE)
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def LIMIT(self) -> Self:
|
|
347
|
+
return self.add(SQL.LIMIT)
|
|
348
|
+
|
|
349
|
+
@property
|
|
350
|
+
def MATCH(self) -> Self:
|
|
351
|
+
return self.add(SQL.MATCH)
|
|
352
|
+
|
|
353
|
+
@property
|
|
354
|
+
def MATERIALIZED(self) -> Self:
|
|
355
|
+
return self.add(SQL.MATERIALIZED)
|
|
356
|
+
|
|
357
|
+
@property
|
|
358
|
+
def NATURAL(self) -> Self:
|
|
359
|
+
return self.add(SQL.NATURAL)
|
|
360
|
+
|
|
361
|
+
@property
|
|
362
|
+
def NO(self) -> Self:
|
|
363
|
+
return self.add(SQL.NO)
|
|
364
|
+
|
|
365
|
+
@property
|
|
366
|
+
def NOT(self) -> Self:
|
|
367
|
+
return self.add(SQL.NOT)
|
|
368
|
+
|
|
369
|
+
@property
|
|
370
|
+
def NOTHING(self) -> Self:
|
|
371
|
+
return self.add(SQL.NOTHING)
|
|
372
|
+
|
|
373
|
+
@property
|
|
374
|
+
def NOTNULL(self) -> Self:
|
|
375
|
+
return self.add(SQL.NOTNULL)
|
|
376
|
+
|
|
377
|
+
@property
|
|
378
|
+
def NULL(self) -> Self:
|
|
379
|
+
return self.add(SQL.NULL)
|
|
380
|
+
|
|
381
|
+
@property
|
|
382
|
+
def NULLS(self) -> Self:
|
|
383
|
+
return self.add(SQL.NULLS)
|
|
384
|
+
|
|
385
|
+
@property
|
|
386
|
+
def OF(self) -> Self:
|
|
387
|
+
return self.add(SQL.OF)
|
|
388
|
+
|
|
389
|
+
@property
|
|
390
|
+
def OFFSET(self) -> Self:
|
|
391
|
+
return self.add(SQL.OFFSET)
|
|
392
|
+
|
|
393
|
+
@property
|
|
394
|
+
def ON(self) -> Self:
|
|
395
|
+
return self.add(SQL.ON)
|
|
396
|
+
|
|
397
|
+
@property
|
|
398
|
+
def OR(self) -> Self:
|
|
399
|
+
return self.add(SQL.OR)
|
|
400
|
+
|
|
401
|
+
@property
|
|
402
|
+
def ORDER(self) -> Self:
|
|
403
|
+
return self.add(SQL.ORDER)
|
|
404
|
+
|
|
405
|
+
@property
|
|
406
|
+
def OTHERS(self) -> Self:
|
|
407
|
+
return self.add(SQL.OTHERS)
|
|
408
|
+
|
|
409
|
+
@property
|
|
410
|
+
def OUTER(self) -> Self:
|
|
411
|
+
return self.add(SQL.OUTER)
|
|
412
|
+
|
|
413
|
+
@property
|
|
414
|
+
def OVER(self) -> Self:
|
|
415
|
+
return self.add(SQL.OVER)
|
|
416
|
+
|
|
417
|
+
@property
|
|
418
|
+
def PARTITION(self) -> Self:
|
|
419
|
+
return self.add(SQL.PARTITION)
|
|
420
|
+
|
|
421
|
+
@property
|
|
422
|
+
def PLAN(self) -> Self:
|
|
423
|
+
return self.add(SQL.PLAN)
|
|
424
|
+
|
|
425
|
+
@property
|
|
426
|
+
def PRAGMA(self) -> Self:
|
|
427
|
+
return self.add(SQL.PRAGMA)
|
|
428
|
+
|
|
429
|
+
@property
|
|
430
|
+
def PRECEDING(self) -> Self:
|
|
431
|
+
return self.add(SQL.PRECEDING)
|
|
432
|
+
|
|
433
|
+
@property
|
|
434
|
+
def PRIMARY(self) -> Self:
|
|
435
|
+
return self.add(SQL.PRIMARY)
|
|
436
|
+
|
|
437
|
+
@property
|
|
438
|
+
def PRIMARY_KEY(self) -> Self:
|
|
439
|
+
return self.add(SQL.PRIMARY_KEY)
|
|
440
|
+
|
|
441
|
+
@property
|
|
442
|
+
def QUERY(self) -> Self:
|
|
443
|
+
return self.add(SQL.QUERY)
|
|
444
|
+
|
|
445
|
+
@property
|
|
446
|
+
def RAISE(self) -> Self:
|
|
447
|
+
return self.add(SQL.RAISE)
|
|
448
|
+
|
|
449
|
+
@property
|
|
450
|
+
def RANGE(self) -> Self:
|
|
451
|
+
return self.add(SQL.RANGE)
|
|
452
|
+
|
|
453
|
+
@property
|
|
454
|
+
def RECURSIVE(self) -> Self:
|
|
455
|
+
return self.add(SQL.RECURSIVE)
|
|
456
|
+
|
|
457
|
+
@property
|
|
458
|
+
def REFERENCES(self) -> Self:
|
|
459
|
+
return self.add(SQL.REFERENCES)
|
|
460
|
+
|
|
461
|
+
@property
|
|
462
|
+
def REGEXP(self) -> Self:
|
|
463
|
+
return self.add(SQL.REGEXP)
|
|
464
|
+
|
|
465
|
+
@property
|
|
466
|
+
def REINDEX(self) -> Self:
|
|
467
|
+
return self.add(SQL.REINDEX)
|
|
468
|
+
|
|
469
|
+
@property
|
|
470
|
+
def RELEASE(self) -> Self:
|
|
471
|
+
return self.add(SQL.RELEASE)
|
|
472
|
+
|
|
473
|
+
@property
|
|
474
|
+
def RENAME(self) -> Self:
|
|
475
|
+
return self.add(SQL.RENAME)
|
|
476
|
+
|
|
477
|
+
@property
|
|
478
|
+
def REPLACE(self) -> Self:
|
|
479
|
+
return self.add(SQL.REPLACE)
|
|
480
|
+
|
|
481
|
+
@property
|
|
482
|
+
def RESTRICT(self) -> Self:
|
|
483
|
+
return self.add(SQL.RESTRICT)
|
|
484
|
+
|
|
485
|
+
@property
|
|
486
|
+
def RETURNING(self) -> Self:
|
|
487
|
+
return self.add(SQL.RETURNING)
|
|
488
|
+
|
|
489
|
+
@property
|
|
490
|
+
def RIGHT(self) -> Self:
|
|
491
|
+
return self.add(SQL.RIGHT)
|
|
492
|
+
|
|
493
|
+
@property
|
|
494
|
+
def ROLLBACK(self) -> Self:
|
|
495
|
+
return self.add(SQL.ROLLBACK)
|
|
496
|
+
|
|
497
|
+
@property
|
|
498
|
+
def ROW(self) -> Self:
|
|
499
|
+
return self.add(SQL.ROW)
|
|
500
|
+
|
|
501
|
+
@property
|
|
502
|
+
def ROWS(self) -> Self:
|
|
503
|
+
return self.add(SQL.ROWS)
|
|
504
|
+
|
|
505
|
+
@property
|
|
506
|
+
def SAVEPOINT(self) -> Self:
|
|
507
|
+
return self.add(SQL.SAVEPOINT)
|
|
508
|
+
|
|
509
|
+
@property
|
|
510
|
+
def SELECT(self) -> Self:
|
|
511
|
+
return self.add(SQL.SELECT)
|
|
512
|
+
|
|
513
|
+
@property
|
|
514
|
+
def SET(self) -> Self:
|
|
515
|
+
return self.add(SQL.SET)
|
|
516
|
+
|
|
517
|
+
@property
|
|
518
|
+
def STORED(self) -> Self:
|
|
519
|
+
return self.add(SQL.STORED)
|
|
520
|
+
|
|
521
|
+
@property
|
|
522
|
+
def TABLE(self) -> Self:
|
|
523
|
+
return self.add(SQL.TABLE)
|
|
524
|
+
|
|
525
|
+
@property
|
|
526
|
+
def TEMP(self) -> Self:
|
|
527
|
+
return self.add(SQL.TEMP)
|
|
528
|
+
|
|
529
|
+
@property
|
|
530
|
+
def TEMPORARY(self) -> Self:
|
|
531
|
+
return self.add(SQL.TEMPORARY)
|
|
532
|
+
|
|
533
|
+
@property
|
|
534
|
+
def THEN(self) -> Self:
|
|
535
|
+
return self.add(SQL.THEN)
|
|
536
|
+
|
|
537
|
+
@property
|
|
538
|
+
def TIES(self) -> Self:
|
|
539
|
+
return self.add(SQL.TIES)
|
|
540
|
+
|
|
541
|
+
@property
|
|
542
|
+
def TO(self) -> Self:
|
|
543
|
+
return self.add(SQL.TO)
|
|
544
|
+
|
|
545
|
+
@property
|
|
546
|
+
def TRANSACTION(self) -> Self:
|
|
547
|
+
return self.add(SQL.TRANSACTION)
|
|
548
|
+
|
|
549
|
+
@property
|
|
550
|
+
def TRIGGER(self) -> Self:
|
|
551
|
+
return self.add(SQL.TRIGGER)
|
|
552
|
+
|
|
553
|
+
@property
|
|
554
|
+
def UNBOUNDED(self) -> Self:
|
|
555
|
+
return self.add(SQL.UNBOUNDED)
|
|
556
|
+
|
|
557
|
+
@property
|
|
558
|
+
def UNION(self) -> Self:
|
|
559
|
+
return self.add(SQL.UNION)
|
|
560
|
+
|
|
561
|
+
@property
|
|
562
|
+
def UNIQUE(self) -> Self:
|
|
563
|
+
return self.add(SQL.UNIQUE)
|
|
564
|
+
|
|
565
|
+
@property
|
|
566
|
+
def UPDATE(self) -> Self:
|
|
567
|
+
return self.add(SQL.UPDATE)
|
|
568
|
+
|
|
569
|
+
@property
|
|
570
|
+
def USING(self) -> Self:
|
|
571
|
+
return self.add(SQL.USING)
|
|
572
|
+
|
|
573
|
+
@property
|
|
574
|
+
def VACUUM(self) -> Self:
|
|
575
|
+
return self.add(SQL.VACUUM)
|
|
576
|
+
|
|
577
|
+
@property
|
|
578
|
+
def VALUES(self) -> Self:
|
|
579
|
+
return self.add(SQL.VALUES)
|
|
580
|
+
|
|
581
|
+
@property
|
|
582
|
+
def VIEW(self) -> Self:
|
|
583
|
+
return self.add(SQL.VIEW)
|
|
584
|
+
|
|
585
|
+
@property
|
|
586
|
+
def VIRTUAL(self) -> Self:
|
|
587
|
+
return self.add(SQL.VIRTUAL)
|
|
588
|
+
|
|
589
|
+
@property
|
|
590
|
+
def WHEN(self) -> Self:
|
|
591
|
+
return self.add(SQL.WHEN)
|
|
592
|
+
|
|
593
|
+
@property
|
|
594
|
+
def WHERE(self) -> Self:
|
|
595
|
+
return self.add(SQL.WHERE)
|
|
596
|
+
|
|
597
|
+
@property
|
|
598
|
+
def WINDOW(self) -> Self:
|
|
599
|
+
return self.add(SQL.WINDOW)
|
|
600
|
+
|
|
601
|
+
@property
|
|
602
|
+
def WITH(self) -> Self:
|
|
603
|
+
return self.add(SQL.WITH)
|
|
604
|
+
|
|
605
|
+
@property
|
|
606
|
+
def WITHOUT(self) -> Self:
|
|
607
|
+
return self.add(SQL.WITHOUT)
|
|
608
|
+
|
|
609
|
+
@property
|
|
610
|
+
def INTEGER(self) -> Self:
|
|
611
|
+
return self.add(SQL.INTEGER)
|
|
612
|
+
|
|
613
|
+
@property
|
|
614
|
+
def TEXT(self) -> Self:
|
|
615
|
+
return self.add(SQL.TEXT)
|
|
616
|
+
|
|
617
|
+
@property
|
|
618
|
+
def BLOB(self) -> Self:
|
|
619
|
+
return self.add(SQL.BLOB)
|
|
620
|
+
|
|
621
|
+
@property
|
|
622
|
+
def REAL(self) -> Self:
|
|
623
|
+
return self.add(SQL.REAL)
|
|
624
|
+
|
|
625
|
+
@property
|
|
626
|
+
def NUMERIC(self) -> Self:
|
|
627
|
+
return self.add(SQL.NUMERIC)
|
|
628
|
+
|
|
629
|
+
@property
|
|
630
|
+
def ANY(self) -> Self:
|
|
631
|
+
return self.add(SQL.ANY)
|
|
632
|
+
|
|
633
|
+
@property
|
|
634
|
+
def OLD(self) -> Self:
|
|
635
|
+
return self.add(SQL.OLD)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from dataclasses import is_dataclass
|
|
2
|
+
from typing import Self
|
|
3
|
+
|
|
4
|
+
import dataclassdb.builders.list_utils as lu
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class StringBuilder:
|
|
8
|
+
def __init__(self, *args, **kwargs):
|
|
9
|
+
self.sep = " "
|
|
10
|
+
self.query = []
|
|
11
|
+
self.br_count = 0
|
|
12
|
+
|
|
13
|
+
def __repr__(self):
|
|
14
|
+
query_str = self.sep.join(map(str, self.query))
|
|
15
|
+
return query_str
|
|
16
|
+
|
|
17
|
+
def __eq__(self, value: object) -> bool:
|
|
18
|
+
return str(self) == value
|
|
19
|
+
|
|
20
|
+
def __call__(
|
|
21
|
+
self, *args, commas=True, par=False, quotes=False, newline=False, **kwargs
|
|
22
|
+
) -> Self:
|
|
23
|
+
if not args:
|
|
24
|
+
return self
|
|
25
|
+
else:
|
|
26
|
+
return self.add(
|
|
27
|
+
*args, commas=commas, par=par, quotes=quotes, newline=newline
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def show(self) -> Self:
|
|
32
|
+
print(self)
|
|
33
|
+
return self
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def br(self) -> Self:
|
|
37
|
+
self.br_count += 1
|
|
38
|
+
return self
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def clear(self) -> Self:
|
|
42
|
+
self.query = []
|
|
43
|
+
self.br_count = 0
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def as_string(self) -> str:
|
|
47
|
+
"""Returns the built string and clears the query
|
|
48
|
+
Returns:
|
|
49
|
+
str: _description_
|
|
50
|
+
"""
|
|
51
|
+
try:
|
|
52
|
+
return str(self)
|
|
53
|
+
finally:
|
|
54
|
+
self.clear
|
|
55
|
+
|
|
56
|
+
def set_sep(self, sep: str) -> Self:
|
|
57
|
+
self.sep = sep
|
|
58
|
+
return self
|
|
59
|
+
|
|
60
|
+
def add(
|
|
61
|
+
self, *args, commas=True, par=False, quotes=False, newline=False, **kwargs
|
|
62
|
+
) -> Self:
|
|
63
|
+
params = [
|
|
64
|
+
arg.__name__ if is_dataclass(arg) else arg
|
|
65
|
+
for arg in lu.flatten(*args) # type: ignore
|
|
66
|
+
]
|
|
67
|
+
if quotes:
|
|
68
|
+
params = lu.add_quotes(params)
|
|
69
|
+
if commas:
|
|
70
|
+
params = lu.add_commas(params)
|
|
71
|
+
if par:
|
|
72
|
+
params = lu.add_parenthesis(params)
|
|
73
|
+
if newline:
|
|
74
|
+
if params:
|
|
75
|
+
params[0] = f"\n{params[0]}"
|
|
76
|
+
if self.br_count:
|
|
77
|
+
prefix = "\n" * int(self.br_count)
|
|
78
|
+
params[0] = f"{prefix}{params[0]}"
|
|
79
|
+
self.br_count = 0
|
|
80
|
+
|
|
81
|
+
for arg in lu.flatten(params):
|
|
82
|
+
if arg is None or arg == "":
|
|
83
|
+
continue
|
|
84
|
+
else:
|
|
85
|
+
self.query.append(arg)
|
|
86
|
+
return self
|
|
87
|
+
|
|
88
|
+
def add_func(self, *args) -> Self:
|
|
89
|
+
params = lu.flatten(*args)
|
|
90
|
+
if not params:
|
|
91
|
+
raise ValueError("Function name must be provided")
|
|
92
|
+
elif len(args) == 1:
|
|
93
|
+
self.add(f"{args[0]}()")
|
|
94
|
+
else:
|
|
95
|
+
params[1:] = lu.add_parenthesis(params[1:])
|
|
96
|
+
params[1] = f"{params[0]}{params[1]}"
|
|
97
|
+
self.add(*params[1:])
|
|
98
|
+
return self
|