Skip to content
Snippets Groups Projects
Commit d0599938 authored by florian's avatar florian
Browse files

DOC: Add short list-value example

parent cf13029a
No related branches found
No related tags found
2 merge requests!33MAINT: change arguments of create_user,!30DOC: Add short list-value example
Pipeline #14557 passed with warnings
......@@ -144,6 +144,28 @@ Useful is also, that you can insert directly tabular data.
With this example file
`test.csv <uploads/4f2c8756a26a3984c0af09d206d583e5/test.csv>`__.
List Properties
---------------
As you may already know, properties may also have list instead of scalar
values. They can be accessed, set, and updated as you would expect from any
list-valued attribute in Python, as the following example illustrates.
.. code:: python
import caosdb as db
db.Property(name="TestList", datatype=db.LIST(db.DOUBLE)).insert()
db.RecordType(name="TestType").add_property(name="TestList").insert()
db.Record(name="TestRec").add_parent("TestType").add_property(
name="TestList", value=[1,2,3]).insert()
retrieved = db.Record(name="TestRec").retrieve()
retrieved.get_property("TestList").value += [4,5]
retrieved.update()
# Check update
retrieved = db.Record(name="TestRec").retrieve()
print(retrieved.get_property("TestList").value)
File Update
-----------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment