Skip to content
Dmitry Romanov edited this page Nov 17, 2015 · 17 revisions

#Python API

Since ccdb command is actually written in python, there are at least 2 ways to interact with CCDB using python.

  1. Using functions that very resembles 'ccdb' command

  2. Using so called low level python API

Using 'ccdb' command like functions:

It looks like this:

    context.process_command_line("mkdir /test/testable2 x y z #Some comment")

Procs:

  • As simple as ccdb command but you get exceptions and don't have to use syscall
  • Documentation from ccdb command works here too
  • It is safe

Cons:

  • You don't get results as python objects. So you can't read tables and do for on them

Using Low Level python API

It looks like this:

 tables = provider.get_type_tables("/test/test_vars")
 for table in tables:
     print(table.name)

Procs:

  • Full access to CCDB data through python
  • Working with python objects
  • SQLAlchemy querries to DB is possible

Cons:

  • More complex
  • One can screw up data layout especially on delete operations (so please, follow instructions and examples, make backups!)