hoie-database-client 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.
@@ -0,0 +1,159 @@
1
+ """The Python client for the database server.
2
+
3
+ from hoie_database_client import *
4
+
5
+ db = Client.connect("database://shop:secret@database:5454")
6
+ db.create_table_if_not_exists(
7
+ TableDef("users")
8
+ .column(ColumnDef("id", Type.UUID).default_random_uuid())
9
+ .column(ColumnDef("username", Type.TEXT))
10
+ .column(ColumnDef("created", Type.TIMESTAMP).default_now())
11
+ .primary_key(["id"])
12
+ .unique("users_username_key", ["username"])
13
+ )
14
+ user_id = db.insert(Insert.into("users").set("username", "ann").returning(["id"])).one()["id"]
15
+ ann = db.query_opt(Query.table("users").index("users_username_key", KeyRange.eq(["ann"])))
16
+
17
+ There is no SQL: a query says which key or index to read and in what
18
+ range, and the server does exactly that. A query that says neither is
19
+ given a range by the server where its filter is one, and answers the
20
+ same either way. ``docs/CLIENT.md`` in
21
+ the repository describes the vocabulary (for the Rust client, which this
22
+ one follows name for name); ``docs/PROTOCOL.md`` is the wire protocol.
23
+ """
24
+
25
+ from . import ast
26
+ from .ast import AggFunc, ArithOp, CmpOp, Direction, Func, JoinKind, OnDelete, SubqueryKind, TextConfig, TxnKind, Type
27
+ from .builders import (
28
+ ALL,
29
+ PRIMARY,
30
+ Bound,
31
+ ColumnDef,
32
+ Delete,
33
+ Expr,
34
+ IndexDef,
35
+ Insert,
36
+ KeyRange,
37
+ Order,
38
+ Query,
39
+ TableDef,
40
+ Update,
41
+ all_,
42
+ any_,
43
+ avg,
44
+ call,
45
+ case,
46
+ coalesce,
47
+ col,
48
+ collect,
49
+ concat,
50
+ count,
51
+ days,
52
+ depth,
53
+ excluded,
54
+ exists,
55
+ greatest,
56
+ hours,
57
+ least,
58
+ like_escape,
59
+ list_,
60
+ list_of,
61
+ max_,
62
+ min_,
63
+ minutes,
64
+ now,
65
+ null,
66
+ old,
67
+ rank,
68
+ scalar,
69
+ seconds,
70
+ sum_,
71
+ val,
72
+ when,
73
+ )
74
+ from .client import Admin, Client, Db, LockGuard, Row, Rows, Transaction
75
+ from .codec import MAX_FRAME, PROTOCOL_VERSION
76
+ from .conn import DEFAULT_PORT, Config, Connector, Tls, Transport
77
+ from .errors import DbError, ErrorCode
78
+ from .values import Date, Json, Timestamp
79
+
80
+ __version__ = "0.1.0"
81
+
82
+ __all__ = [
83
+ "ALL",
84
+ "Admin",
85
+ "AggFunc",
86
+ "ArithOp",
87
+ "Bound",
88
+ "Client",
89
+ "CmpOp",
90
+ "ColumnDef",
91
+ "Config",
92
+ "Connector",
93
+ "DEFAULT_PORT",
94
+ "Date",
95
+ "Db",
96
+ "DbError",
97
+ "Delete",
98
+ "Direction",
99
+ "ErrorCode",
100
+ "Expr",
101
+ "Func",
102
+ "IndexDef",
103
+ "Insert",
104
+ "JoinKind",
105
+ "Json",
106
+ "KeyRange",
107
+ "LockGuard",
108
+ "MAX_FRAME",
109
+ "OnDelete",
110
+ "Order",
111
+ "PRIMARY",
112
+ "PROTOCOL_VERSION",
113
+ "Query",
114
+ "Row",
115
+ "Rows",
116
+ "SubqueryKind",
117
+ "TableDef",
118
+ "TextConfig",
119
+ "Timestamp",
120
+ "Tls",
121
+ "Transaction",
122
+ "Transport",
123
+ "TxnKind",
124
+ "Type",
125
+ "Update",
126
+ "all_",
127
+ "any_",
128
+ "ast",
129
+ "avg",
130
+ "call",
131
+ "case",
132
+ "coalesce",
133
+ "col",
134
+ "collect",
135
+ "concat",
136
+ "count",
137
+ "days",
138
+ "depth",
139
+ "excluded",
140
+ "exists",
141
+ "greatest",
142
+ "hours",
143
+ "least",
144
+ "like_escape",
145
+ "list_",
146
+ "list_of",
147
+ "max_",
148
+ "min_",
149
+ "minutes",
150
+ "now",
151
+ "null",
152
+ "old",
153
+ "rank",
154
+ "scalar",
155
+ "seconds",
156
+ "sum_",
157
+ "val",
158
+ "when",
159
+ ]