diff --git a/examples/pycaosdb_example.py b/examples/pycaosdb_example.py index d128e4e6d01d3d868960c2646a18919f8f7be2f2..c7eab4a64e6797f26b49716499ee4e0267b167a1 100755 --- a/examples/pycaosdb_example.py +++ b/examples/pycaosdb_example.py @@ -6,12 +6,19 @@ Make sure that a `pycaosdb.ini` is readable at one of the expected locations. import random -import caosdb +import caosdb as db + + +def reconfigure_connection(): + """Change the current connection configuration.""" + conf = db.configuration.get_config() + conf.set("Connection", "url", "https://demo.indiscale.com") + db.configure_connection() def main(): """Shows a few examples how to use the CaosDB library.""" - conf = dict(caosdb.configuration.get_config().items("Connection")) + conf = dict(db.configuration.get_config().items("Connection")) print("##### Config:\n{}\n".format(conf)) if conf["cacert"] == "/path/to/caosdb.ca.pem": @@ -19,12 +26,12 @@ def main(): "please fix it.") # Query the server, the result is a Container - result = caosdb.Query("FIND Record").execute() + result = db.Query("FIND Record").execute() print("##### First query result:\n{}\n".format(result[0])) # Retrieve a random Record rec_id = random.choice([rec.id for rec in result]) - rec = caosdb.Record(id=rec_id).retrieve() + rec = db.Record(id=rec_id).retrieve() print("##### Randomly retrieved Record:\n{}\n".format(rec))