18
18
You can install this project using pip:
19
19
20
20
``` bash
21
- pip install xtdb
21
+ $ pip install xtdb
22
22
```
23
23
24
24
## Usage
@@ -30,7 +30,7 @@ $ docker run -p 3000:3000 -d juxt/xtdb-standalone-rocksdb:1.21.0
30
30
$ export XTDB_URI=http://localhost:3000/_xtdb
31
31
```
32
32
33
- ### Using the client
33
+ ### Using the Client
34
34
35
35
The ` XTDBClient ` supports the full [ HTTP API spec] ( https://docs.xtdb.com/clients/http/ ) .
36
36
@@ -48,7 +48,9 @@ The `XTDBClient` supports the full [HTTP API spec](https://docs.xtdb.com/clients
48
48
{' name' : ' fred' , ' xt/id' : ' 123' }
49
49
```
50
50
51
- ### Datalog Query Support
51
+ Take a look at the spec to see the full range of functionality that maps directly to the client.
52
+
53
+ ### Using the Datalog module
52
54
53
55
The [ datalog] ( xtdb/datalog.py ) module also provides a layer to construct queries with more easily.
54
56
Given the data from [ the cities example] ( examples/cities ) has been seeded:
@@ -65,7 +67,7 @@ Given the data from [the cities example](examples/cities) has been seeded:
65
67
66
68
To see more datalog query examples, check out the [ unit tests] ( tests/test_datalog.py ) .
67
69
68
- ### Using the ORM
70
+ ### Using the ORM and Session
69
71
70
72
Below is an example of how to use the ORM functionality.
71
73
@@ -109,41 +111,18 @@ This package also comes with an easy CLI tool to query XTDB.
109
111
To query XTDB using a plain query you can run
110
112
111
113
``` bash
112
- $ echo ' {:query {:find [(pull ?e [*])] :where [[ ?e :name "fred" ]]}}' | python -m xtdb | jq
113
- [
114
- [
115
- {
116
- " xt/id" : " 123"
117
- " name" : " fred" ,
118
- " somenil" : null,
119
- " somedict" : {
120
- " c" : 3,
121
- " a" : " b"
122
- },
123
- }
124
- ]
125
- ]
114
+ $ echo ' {:query {:find [(pull ?e [*])] :where [[ ?e :name "fred" ]]}}' | python -m xtdb
115
+ [[{" name" : " fred" , " xt/id" : " 123" }]]
126
116
```
127
117
128
118
To use a query file the command can be modified to the following:
129
119
130
120
``` bash
131
121
$ cat query.txt
132
122
{:query {:find [(pull ? e [* ])] :where [[ ? e :name " fred" ]]}}
133
- $ python -m xtdb < query.txt | jq
134
- [
135
- [
136
- {
137
- " xt/id" : " 123"
138
- " name" : " fred" ,
139
- " somenil" : null,
140
- " somedict" : {
141
- " c" : 3,
142
- " a" : " b"
143
- },
144
- }
145
- ]
146
- ]
123
+ $
124
+ $ python -m xtdb < query.txt
125
+ [[{" name" : " fred" , " xt/id" : " 123" }]]
147
126
```
148
127
149
128
## Contributing
0 commit comments