Skip to content

Connect to CrossDB

You need a connection instance to connect to CrossDB, and all operations will use this connection handle.

  • Each thread can use only one connection, and each connection can be used by only one thread.
  • All opened databases are shared among all opened connections, and you can use USE DATABASE db_name command to switch the connection's default database.

C APIs

  • Open a connection
xdb_conn_t *pConn = xdb_open (NULL);

Note

User has to use OPEN DATABASE '[path/]db_name' or CREATE DATABASE '[path/]db_name' or USE DATABASE db_name.

  • Open a connection and create a default memory database if not exist
xdb_conn_t *pConn = xdb_open (":memory:");
  • Open a connection and create a on-disk database school if not exist as the default database
//  In current folder
xdb_conn_t *pConn = xdb_open ("school");
// In specified folder
xdb_conn_t *pConn = xdb_open ("/var/crossdb/school");

Comments