bg
Database – Embedded C++ – BangDB = NoSQL + AI + Stream

Database – Embedded C++

chevron

Database

Embedded C++

We create database simply as shown. This should be the first thing that we do before doing anything else.

	db_param dp;
	dp.setTransactionType(DB_TRANSACTION_NONE);
	bangdb_database *bdb = bangdb_database::getInstance("mydb", &dp);
	if(!bdb)
	{
		printf("db could not be created, quitting\n");
		// handle error, possibly return from here
	}
	// db_param sets the db environment, see the section to know more about it
Note: We must tell db where to find the bangdb.config file. This can be done by either keeping the file in the same dir as your application in case of embedded or in case of server the same dir as server. We can override this by setting the configPath in db_param before calling getInstance

db_Param is used to set the db environment. It is described as below;

// db related data, right now we send following to db db_transaction_type _tranType; // if db should be opened in transactional or non-transactional mode // pls note, db could be stopped and started in different way as needed // as far as transaction mode is concerned const char *_configPath; // path to bangdb.config file, optional - default is local current dir const char *_dbPath; // path where db files will be kept, optional - default is data dir in current dir const char *_dbLogPath; // path where log files will be kept, optional - default is logdir dir in current dir const char *_dbArchivePath; // path where archive files will be kept, optional - default is archive dir in current dir // following are only true for clients connecting over network const char *_host; // server ip const char *_port; // server port const char *_userid; // NULL for now const char *_password; // NULL for now bool _init_sock_conns; // true, as it inits the connection pool bool _tls_conn; // true if connecting over ssl else false. Note server and client should run in same manner char _reserved[2]; // nothing, just for alignment