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
|
%global _empty_manifest_terminate_build 0
Name: python-terminusdb-client
Version: 10.2.3
Release: 1
Summary: Python client for Terminus DB
License: Apache Software License
URL: https://github.com/terminusdb/terminusdb-client-python
Source0: https://mirrors.aliyun.com/pypi/web/packages/dd/dd/ca399e553c7f61faa53dac64aa74f0b84d8499e33b4e334a4b1f3723c6cb/terminusdb-client-10.2.3.tar.gz
BuildArch: noarch
Requires: python3-requests
Requires: python3-numpydoc
Requires: python3-click
Requires: python3-shed
Requires: python3-typeguard
Requires: python3-tqdm
Requires: python3-numpy
Requires: python3-pandas
%description
[](https://discord.gg/yTJKAma)
[](https://www.reddit.com/r/TerminusDB/)
[](https://twitter.com/TerminusDB)
[](https://pypi.python.org/pypi/terminusdb-client/)
[](https://pypi.python.org/pypi/terminusdb-client/)
[](https://github.com/terminusdb/terminusdb-client-python/actions)
[](https://terminusdb.com/docs/guides/reference-guides/python-client-reference)
[](https://codecov.io/gh/terminusdb/terminusdb-client-python)
[](https://github.com/terminusdb/terminusdb-client-python/blob/main/LICENSE)
> Python client for TerminusDB and TerminusCMS.
[**TerminusDB**][terminusdb] is an [open-source][terminusdb-repo] graph database
and document store. It allows you to link JSON documents in a powerful knowledge
graph all through a simple document API.
[terminusdb]: https://terminusdb.com/
[terminusdb-docs]: https://terminusdb.com/docs/
[terminusdb-repo]: https://github.com/terminusdb/terminusdb
[**TerminusCMS**](https://terminusdb.com/terminuscms/) is a hosted headless content management system. It is built upon TerminusDB and is a developer focused data management platform for complex data and content infrastructure. [Sign up and clone a demo project to see how it works][dashboard].
[dashboard]: https://dashboard.terminusdb.com/
## Requirements
- [TerminusDB v10.0](https://github.com/terminusdb/terminusdb-server)
- [Python >=3.7](https://www.python.org/downloads)
## Release Notes and Previous Versions
TerminusDB Client v10.0 works with TerminusDB v10.0 and TerminusCMS. Please check the [Release Notes](https://github.com/terminusdb/terminusdb-client-python/blob/master/RELEASE_NOTES.md) to find out what has changed.
## Installation
- TerminusDB Client can be downloaded form PyPI using pip:
`python -m pip install terminusdb-client`
This only includes the core Python Client (Client) and WOQLQuery.
If you want to use woqlDataframe or the import and export csv function in Scaffolding CLI tool:
`python -m pip install terminusdb-client[dataframe]`
*if you are installing form `zsh` you have to quote the argument like this:*
`python -m pip install 'terminusdb-client[dataframe]'`
- Install from source:
`python -m pip install git+https://github.com/terminusdb/terminusdb-client-python.git`
## Demo

## Usage
### Python client
#### Connect to a server
Connect to local host
```Python
from terminusdb_client import Client
client = Client("http://127.0.0.1:6363/")
client.connect()
```
Connect to TerminusCMS
*check documentation for TerminusCMS about how to add the [API token](https://terminusdb.com/docs/terminuscms/get-api-key) to the environment variable*
```Python
from terminusdb_client import Client
team="MyTeam"
client = Client(f"https://dashboard.terminusdb.com/{team}/")
client.connect(team="MyTeam", use_token=True)
```
#### Create a database
```Python
client.create_database("MyDatabase")
```
#### Create a schema
```Python
from terminusdb_client.schema import Schema, DocumentTemplate, RandomKey
my_schema = Schema()
class Pet(DocumentTemplate):
_schema = my_schema
name: str
species: str
age: int
weight: float
my_schema.commit(client)
```
#### Create and insert doucments
```Python
my_dog = Pet(name="Honda", species="Huskey", age=3, weight=21.1)
my_cat = Pet(name="Tiger", species="Bengal cat", age=5, weight=4.5)
client.insert_document([my_dog, my_cat])
```
#### Get back all documents
```Python
print(list(client.get_all_documents()))
```
```
[{'@id': 'Pet/b5edacf854e34fe79c228a91e2af45fb', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}, {'@id': 'Pet/cdbe3f6d49394b38b952ae315309256d', '@type': 'Pet', 'age': 3, 'name': 'Honda', 'species': 'Huskey', 'weight': 21.1}]
```
#### Get a specific document
```Python
print(list(client.query_document({"@type":"Pet", "age":5})))
```
```
[{'@id': 'Pet/145eb73966d14a1394f7cd5576d7d0b8', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}]
```
#### Delete a database
```Python
client.delete_database("MyDatabase")
```
### Scaffolding CLI tool

Start a project in the directory
```bash
$ tdbpy startproject
Please enter a project name (this will also be the database name): mydb
Please enter a endpoint location (press enter to use localhost default) [http://127.0.0.1:6363/]:
config.json and schema.py created, please customize them to start your project.
```
Import a CSV named `grades.csv`
``` bash
$ tdbpy importcsv grades.csv --na=error
0it [00:00, ?it/s]
Schema object Grades created with grades.csv inserted into database.
schema.py is updated with mydb schema.
1it [00:00, 1.00it/s]
Records in grades.csv inserted as type Grades into database with Lexical ids.
```
Get documents with query
```bash
$ tdbpy alldocs --type Grades -q grade="B-"
[{'@id': 'Grades/Android_Electric_087-65-4321_42.0_23.0_36.0_45.0_47.0_B-', '@type': 'Grades', 'final': 47.0, 'first_name': 'Electric', 'grade': 'B-', 'last_name': 'Android', 'ssn': '087-65-4321', 'test1': 42.0, 'test2': 23.0, 'test3': 36.0, 'test4': 45.0}, {'@id': 'Grades/Elephant_Ima_456-71-9012_45.0_1.0_78.0_88.0_77.0_B-', '@type': 'Grades', 'final': 77.0, 'first_name': 'Ima', 'grade': 'B-', 'last_name': 'Elephant', 'ssn': '456-71-9012', 'test1': 45.0, 'test2': 1.0, 'test3': 78.0, 'test4': 88.0}, {'@id': 'Grades/Franklin_Benny_234-56-2890_50.0_1.0_90.0_80.0_90.0_B-', '@type': 'Grades', 'final': 90.0, 'first_name': 'Benny', 'grade': 'B-', 'last_name': 'Franklin', 'ssn': '234-56-2890', 'test1': 50.0, 'test2': 1.0, 'test3': 90.0, 'test4': 80.0}]
```
Delete the database
```bash
$ tdbpy deletedb
Do you want to delete 'mydb'? WARNING: This opertation is non-reversible. [y/N]: y
mydb deleted.
```
### Please check the [full Documentation](https://terminusdb.com/docs/guides/reference-guides/python-client-reference) for more information.
## Guides & Tutorials
Visit our documentation for a range of short how to guides, [how-to use the Python Client](https://terminusdb.com/docs/guides/how-to-guides/use-the-python-client) and [how to use the collaboration features with the Python Client](https://terminusdb.com/docs/guides/how-to-guides/use-collaboration-features/with-the-python-client). Alternatively, undertake the [Getting Started with the Python Client Tutorial Series.](https://github.com/terminusdb/terminusdb-tutorials/blob/main/getting_started/python-client/README.md).
## Testing
1. Clone this repository
`git clone https://github.com/terminusdb/terminusdb-client-python.git`
2. Install all development dependencies using poetry
```sh
$ make init
```
3. (a) To run test files only
```sh
$ poetry run pytest terminusdb_client/tests
```
3. (b) To run full test
```sh
$ poetry run tox -e test
```
Or you can run tests in [poetry shell](https://python-poetry.org/docs/basic-usage/#activating-the-virtual-environment) then no need to use `poetry run`
## Documentation
Visit our [TerminusDB Documentation][terminusdb-docs] for the full explanation of using TerminusDB.
Documentation specifically on the latest version of the Python Client can be found [here][terminusdb-client-python-docs].
### Generating Documentation Locally using Sphinx
1. Clone this repository
`git clone https://github.com/terminusdb/terminusdb-client-python.git`
2. Install all development dependencies
```sh
$ make init
```
3. Change directory to docs
```sh
$ cd docs/
```
4. Build with Sphinx
```sh
$ make html
```
The output files are under `docs/build/html`, open `index.html` in your browser to inspect.
## Report Issues
If you encounter any issues, please [report them](https://github.com/terminusdb/terminusdb-client-python/issues) with your os and environment setup, the version that you are using and a simple reproducible case.
If you have other questions, you can ask in our community [community Subreddit](https://www.reddit.com/r/TerminusDB/) or [Discord server](https://discord.gg/Gvdqw97).
## Community
Come visit us on our [discord server](https://discord.gg/yTJKAma)
or our [community Subreddit](https://www.reddit.com/r/TerminusDB/). We are also on [twitter](https://twitter.com/TerminusDB)
<img align="right" src="https://assets.terminusdb.com/images/TerminusDB%20color%20mascot.png" width="256px"/>
## Contribute
It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add some test(s) of what value you adding.
Please check [CONTRIBUTING.md](https://github.com/terminusdb/terminusdb-client-python/blob/master/CONTRIBUTING.md) for more information.
## Licence
Apache License (Version 2.0)
Copyright (c) 2019
%package -n python3-terminusdb-client
Summary: Python client for Terminus DB
Provides: python-terminusdb-client
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-terminusdb-client
[](https://discord.gg/yTJKAma)
[](https://www.reddit.com/r/TerminusDB/)
[](https://twitter.com/TerminusDB)
[](https://pypi.python.org/pypi/terminusdb-client/)
[](https://pypi.python.org/pypi/terminusdb-client/)
[](https://github.com/terminusdb/terminusdb-client-python/actions)
[](https://terminusdb.com/docs/guides/reference-guides/python-client-reference)
[](https://codecov.io/gh/terminusdb/terminusdb-client-python)
[](https://github.com/terminusdb/terminusdb-client-python/blob/main/LICENSE)
> Python client for TerminusDB and TerminusCMS.
[**TerminusDB**][terminusdb] is an [open-source][terminusdb-repo] graph database
and document store. It allows you to link JSON documents in a powerful knowledge
graph all through a simple document API.
[terminusdb]: https://terminusdb.com/
[terminusdb-docs]: https://terminusdb.com/docs/
[terminusdb-repo]: https://github.com/terminusdb/terminusdb
[**TerminusCMS**](https://terminusdb.com/terminuscms/) is a hosted headless content management system. It is built upon TerminusDB and is a developer focused data management platform for complex data and content infrastructure. [Sign up and clone a demo project to see how it works][dashboard].
[dashboard]: https://dashboard.terminusdb.com/
## Requirements
- [TerminusDB v10.0](https://github.com/terminusdb/terminusdb-server)
- [Python >=3.7](https://www.python.org/downloads)
## Release Notes and Previous Versions
TerminusDB Client v10.0 works with TerminusDB v10.0 and TerminusCMS. Please check the [Release Notes](https://github.com/terminusdb/terminusdb-client-python/blob/master/RELEASE_NOTES.md) to find out what has changed.
## Installation
- TerminusDB Client can be downloaded form PyPI using pip:
`python -m pip install terminusdb-client`
This only includes the core Python Client (Client) and WOQLQuery.
If you want to use woqlDataframe or the import and export csv function in Scaffolding CLI tool:
`python -m pip install terminusdb-client[dataframe]`
*if you are installing form `zsh` you have to quote the argument like this:*
`python -m pip install 'terminusdb-client[dataframe]'`
- Install from source:
`python -m pip install git+https://github.com/terminusdb/terminusdb-client-python.git`
## Demo

## Usage
### Python client
#### Connect to a server
Connect to local host
```Python
from terminusdb_client import Client
client = Client("http://127.0.0.1:6363/")
client.connect()
```
Connect to TerminusCMS
*check documentation for TerminusCMS about how to add the [API token](https://terminusdb.com/docs/terminuscms/get-api-key) to the environment variable*
```Python
from terminusdb_client import Client
team="MyTeam"
client = Client(f"https://dashboard.terminusdb.com/{team}/")
client.connect(team="MyTeam", use_token=True)
```
#### Create a database
```Python
client.create_database("MyDatabase")
```
#### Create a schema
```Python
from terminusdb_client.schema import Schema, DocumentTemplate, RandomKey
my_schema = Schema()
class Pet(DocumentTemplate):
_schema = my_schema
name: str
species: str
age: int
weight: float
my_schema.commit(client)
```
#### Create and insert doucments
```Python
my_dog = Pet(name="Honda", species="Huskey", age=3, weight=21.1)
my_cat = Pet(name="Tiger", species="Bengal cat", age=5, weight=4.5)
client.insert_document([my_dog, my_cat])
```
#### Get back all documents
```Python
print(list(client.get_all_documents()))
```
```
[{'@id': 'Pet/b5edacf854e34fe79c228a91e2af45fb', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}, {'@id': 'Pet/cdbe3f6d49394b38b952ae315309256d', '@type': 'Pet', 'age': 3, 'name': 'Honda', 'species': 'Huskey', 'weight': 21.1}]
```
#### Get a specific document
```Python
print(list(client.query_document({"@type":"Pet", "age":5})))
```
```
[{'@id': 'Pet/145eb73966d14a1394f7cd5576d7d0b8', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}]
```
#### Delete a database
```Python
client.delete_database("MyDatabase")
```
### Scaffolding CLI tool

Start a project in the directory
```bash
$ tdbpy startproject
Please enter a project name (this will also be the database name): mydb
Please enter a endpoint location (press enter to use localhost default) [http://127.0.0.1:6363/]:
config.json and schema.py created, please customize them to start your project.
```
Import a CSV named `grades.csv`
``` bash
$ tdbpy importcsv grades.csv --na=error
0it [00:00, ?it/s]
Schema object Grades created with grades.csv inserted into database.
schema.py is updated with mydb schema.
1it [00:00, 1.00it/s]
Records in grades.csv inserted as type Grades into database with Lexical ids.
```
Get documents with query
```bash
$ tdbpy alldocs --type Grades -q grade="B-"
[{'@id': 'Grades/Android_Electric_087-65-4321_42.0_23.0_36.0_45.0_47.0_B-', '@type': 'Grades', 'final': 47.0, 'first_name': 'Electric', 'grade': 'B-', 'last_name': 'Android', 'ssn': '087-65-4321', 'test1': 42.0, 'test2': 23.0, 'test3': 36.0, 'test4': 45.0}, {'@id': 'Grades/Elephant_Ima_456-71-9012_45.0_1.0_78.0_88.0_77.0_B-', '@type': 'Grades', 'final': 77.0, 'first_name': 'Ima', 'grade': 'B-', 'last_name': 'Elephant', 'ssn': '456-71-9012', 'test1': 45.0, 'test2': 1.0, 'test3': 78.0, 'test4': 88.0}, {'@id': 'Grades/Franklin_Benny_234-56-2890_50.0_1.0_90.0_80.0_90.0_B-', '@type': 'Grades', 'final': 90.0, 'first_name': 'Benny', 'grade': 'B-', 'last_name': 'Franklin', 'ssn': '234-56-2890', 'test1': 50.0, 'test2': 1.0, 'test3': 90.0, 'test4': 80.0}]
```
Delete the database
```bash
$ tdbpy deletedb
Do you want to delete 'mydb'? WARNING: This opertation is non-reversible. [y/N]: y
mydb deleted.
```
### Please check the [full Documentation](https://terminusdb.com/docs/guides/reference-guides/python-client-reference) for more information.
## Guides & Tutorials
Visit our documentation for a range of short how to guides, [how-to use the Python Client](https://terminusdb.com/docs/guides/how-to-guides/use-the-python-client) and [how to use the collaboration features with the Python Client](https://terminusdb.com/docs/guides/how-to-guides/use-collaboration-features/with-the-python-client). Alternatively, undertake the [Getting Started with the Python Client Tutorial Series.](https://github.com/terminusdb/terminusdb-tutorials/blob/main/getting_started/python-client/README.md).
## Testing
1. Clone this repository
`git clone https://github.com/terminusdb/terminusdb-client-python.git`
2. Install all development dependencies using poetry
```sh
$ make init
```
3. (a) To run test files only
```sh
$ poetry run pytest terminusdb_client/tests
```
3. (b) To run full test
```sh
$ poetry run tox -e test
```
Or you can run tests in [poetry shell](https://python-poetry.org/docs/basic-usage/#activating-the-virtual-environment) then no need to use `poetry run`
## Documentation
Visit our [TerminusDB Documentation][terminusdb-docs] for the full explanation of using TerminusDB.
Documentation specifically on the latest version of the Python Client can be found [here][terminusdb-client-python-docs].
### Generating Documentation Locally using Sphinx
1. Clone this repository
`git clone https://github.com/terminusdb/terminusdb-client-python.git`
2. Install all development dependencies
```sh
$ make init
```
3. Change directory to docs
```sh
$ cd docs/
```
4. Build with Sphinx
```sh
$ make html
```
The output files are under `docs/build/html`, open `index.html` in your browser to inspect.
## Report Issues
If you encounter any issues, please [report them](https://github.com/terminusdb/terminusdb-client-python/issues) with your os and environment setup, the version that you are using and a simple reproducible case.
If you have other questions, you can ask in our community [community Subreddit](https://www.reddit.com/r/TerminusDB/) or [Discord server](https://discord.gg/Gvdqw97).
## Community
Come visit us on our [discord server](https://discord.gg/yTJKAma)
or our [community Subreddit](https://www.reddit.com/r/TerminusDB/). We are also on [twitter](https://twitter.com/TerminusDB)
<img align="right" src="https://assets.terminusdb.com/images/TerminusDB%20color%20mascot.png" width="256px"/>
## Contribute
It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add some test(s) of what value you adding.
Please check [CONTRIBUTING.md](https://github.com/terminusdb/terminusdb-client-python/blob/master/CONTRIBUTING.md) for more information.
## Licence
Apache License (Version 2.0)
Copyright (c) 2019
%package help
Summary: Development documents and examples for terminusdb-client
Provides: python3-terminusdb-client-doc
%description help
[](https://discord.gg/yTJKAma)
[](https://www.reddit.com/r/TerminusDB/)
[](https://twitter.com/TerminusDB)
[](https://pypi.python.org/pypi/terminusdb-client/)
[](https://pypi.python.org/pypi/terminusdb-client/)
[](https://github.com/terminusdb/terminusdb-client-python/actions)
[](https://terminusdb.com/docs/guides/reference-guides/python-client-reference)
[](https://codecov.io/gh/terminusdb/terminusdb-client-python)
[](https://github.com/terminusdb/terminusdb-client-python/blob/main/LICENSE)
> Python client for TerminusDB and TerminusCMS.
[**TerminusDB**][terminusdb] is an [open-source][terminusdb-repo] graph database
and document store. It allows you to link JSON documents in a powerful knowledge
graph all through a simple document API.
[terminusdb]: https://terminusdb.com/
[terminusdb-docs]: https://terminusdb.com/docs/
[terminusdb-repo]: https://github.com/terminusdb/terminusdb
[**TerminusCMS**](https://terminusdb.com/terminuscms/) is a hosted headless content management system. It is built upon TerminusDB and is a developer focused data management platform for complex data and content infrastructure. [Sign up and clone a demo project to see how it works][dashboard].
[dashboard]: https://dashboard.terminusdb.com/
## Requirements
- [TerminusDB v10.0](https://github.com/terminusdb/terminusdb-server)
- [Python >=3.7](https://www.python.org/downloads)
## Release Notes and Previous Versions
TerminusDB Client v10.0 works with TerminusDB v10.0 and TerminusCMS. Please check the [Release Notes](https://github.com/terminusdb/terminusdb-client-python/blob/master/RELEASE_NOTES.md) to find out what has changed.
## Installation
- TerminusDB Client can be downloaded form PyPI using pip:
`python -m pip install terminusdb-client`
This only includes the core Python Client (Client) and WOQLQuery.
If you want to use woqlDataframe or the import and export csv function in Scaffolding CLI tool:
`python -m pip install terminusdb-client[dataframe]`
*if you are installing form `zsh` you have to quote the argument like this:*
`python -m pip install 'terminusdb-client[dataframe]'`
- Install from source:
`python -m pip install git+https://github.com/terminusdb/terminusdb-client-python.git`
## Demo

## Usage
### Python client
#### Connect to a server
Connect to local host
```Python
from terminusdb_client import Client
client = Client("http://127.0.0.1:6363/")
client.connect()
```
Connect to TerminusCMS
*check documentation for TerminusCMS about how to add the [API token](https://terminusdb.com/docs/terminuscms/get-api-key) to the environment variable*
```Python
from terminusdb_client import Client
team="MyTeam"
client = Client(f"https://dashboard.terminusdb.com/{team}/")
client.connect(team="MyTeam", use_token=True)
```
#### Create a database
```Python
client.create_database("MyDatabase")
```
#### Create a schema
```Python
from terminusdb_client.schema import Schema, DocumentTemplate, RandomKey
my_schema = Schema()
class Pet(DocumentTemplate):
_schema = my_schema
name: str
species: str
age: int
weight: float
my_schema.commit(client)
```
#### Create and insert doucments
```Python
my_dog = Pet(name="Honda", species="Huskey", age=3, weight=21.1)
my_cat = Pet(name="Tiger", species="Bengal cat", age=5, weight=4.5)
client.insert_document([my_dog, my_cat])
```
#### Get back all documents
```Python
print(list(client.get_all_documents()))
```
```
[{'@id': 'Pet/b5edacf854e34fe79c228a91e2af45fb', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}, {'@id': 'Pet/cdbe3f6d49394b38b952ae315309256d', '@type': 'Pet', 'age': 3, 'name': 'Honda', 'species': 'Huskey', 'weight': 21.1}]
```
#### Get a specific document
```Python
print(list(client.query_document({"@type":"Pet", "age":5})))
```
```
[{'@id': 'Pet/145eb73966d14a1394f7cd5576d7d0b8', '@type': 'Pet', 'age': 5, 'name': 'Tiger', 'species': 'Bengal cat', 'weight': 4.5}]
```
#### Delete a database
```Python
client.delete_database("MyDatabase")
```
### Scaffolding CLI tool

Start a project in the directory
```bash
$ tdbpy startproject
Please enter a project name (this will also be the database name): mydb
Please enter a endpoint location (press enter to use localhost default) [http://127.0.0.1:6363/]:
config.json and schema.py created, please customize them to start your project.
```
Import a CSV named `grades.csv`
``` bash
$ tdbpy importcsv grades.csv --na=error
0it [00:00, ?it/s]
Schema object Grades created with grades.csv inserted into database.
schema.py is updated with mydb schema.
1it [00:00, 1.00it/s]
Records in grades.csv inserted as type Grades into database with Lexical ids.
```
Get documents with query
```bash
$ tdbpy alldocs --type Grades -q grade="B-"
[{'@id': 'Grades/Android_Electric_087-65-4321_42.0_23.0_36.0_45.0_47.0_B-', '@type': 'Grades', 'final': 47.0, 'first_name': 'Electric', 'grade': 'B-', 'last_name': 'Android', 'ssn': '087-65-4321', 'test1': 42.0, 'test2': 23.0, 'test3': 36.0, 'test4': 45.0}, {'@id': 'Grades/Elephant_Ima_456-71-9012_45.0_1.0_78.0_88.0_77.0_B-', '@type': 'Grades', 'final': 77.0, 'first_name': 'Ima', 'grade': 'B-', 'last_name': 'Elephant', 'ssn': '456-71-9012', 'test1': 45.0, 'test2': 1.0, 'test3': 78.0, 'test4': 88.0}, {'@id': 'Grades/Franklin_Benny_234-56-2890_50.0_1.0_90.0_80.0_90.0_B-', '@type': 'Grades', 'final': 90.0, 'first_name': 'Benny', 'grade': 'B-', 'last_name': 'Franklin', 'ssn': '234-56-2890', 'test1': 50.0, 'test2': 1.0, 'test3': 90.0, 'test4': 80.0}]
```
Delete the database
```bash
$ tdbpy deletedb
Do you want to delete 'mydb'? WARNING: This opertation is non-reversible. [y/N]: y
mydb deleted.
```
### Please check the [full Documentation](https://terminusdb.com/docs/guides/reference-guides/python-client-reference) for more information.
## Guides & Tutorials
Visit our documentation for a range of short how to guides, [how-to use the Python Client](https://terminusdb.com/docs/guides/how-to-guides/use-the-python-client) and [how to use the collaboration features with the Python Client](https://terminusdb.com/docs/guides/how-to-guides/use-collaboration-features/with-the-python-client). Alternatively, undertake the [Getting Started with the Python Client Tutorial Series.](https://github.com/terminusdb/terminusdb-tutorials/blob/main/getting_started/python-client/README.md).
## Testing
1. Clone this repository
`git clone https://github.com/terminusdb/terminusdb-client-python.git`
2. Install all development dependencies using poetry
```sh
$ make init
```
3. (a) To run test files only
```sh
$ poetry run pytest terminusdb_client/tests
```
3. (b) To run full test
```sh
$ poetry run tox -e test
```
Or you can run tests in [poetry shell](https://python-poetry.org/docs/basic-usage/#activating-the-virtual-environment) then no need to use `poetry run`
## Documentation
Visit our [TerminusDB Documentation][terminusdb-docs] for the full explanation of using TerminusDB.
Documentation specifically on the latest version of the Python Client can be found [here][terminusdb-client-python-docs].
### Generating Documentation Locally using Sphinx
1. Clone this repository
`git clone https://github.com/terminusdb/terminusdb-client-python.git`
2. Install all development dependencies
```sh
$ make init
```
3. Change directory to docs
```sh
$ cd docs/
```
4. Build with Sphinx
```sh
$ make html
```
The output files are under `docs/build/html`, open `index.html` in your browser to inspect.
## Report Issues
If you encounter any issues, please [report them](https://github.com/terminusdb/terminusdb-client-python/issues) with your os and environment setup, the version that you are using and a simple reproducible case.
If you have other questions, you can ask in our community [community Subreddit](https://www.reddit.com/r/TerminusDB/) or [Discord server](https://discord.gg/Gvdqw97).
## Community
Come visit us on our [discord server](https://discord.gg/yTJKAma)
or our [community Subreddit](https://www.reddit.com/r/TerminusDB/). We are also on [twitter](https://twitter.com/TerminusDB)
<img align="right" src="https://assets.terminusdb.com/images/TerminusDB%20color%20mascot.png" width="256px"/>
## Contribute
It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add some test(s) of what value you adding.
Please check [CONTRIBUTING.md](https://github.com/terminusdb/terminusdb-client-python/blob/master/CONTRIBUTING.md) for more information.
## Licence
Apache License (Version 2.0)
Copyright (c) 2019
%prep
%autosetup -n terminusdb-client-10.2.3
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-terminusdb-client -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri Jun 09 2023 Python_Bot <Python_Bot@openeuler.org> - 10.2.3-1
- Package Spec generated
|