Create/Open Databases in Python

In-memory databases are created in Python by the eXtremeDB wrapper (exdb) method open_database(). For example:

 
    db = exdb.open_database("myopendb", dict)
     

This uses default argument values to create an in-memory database with the name “myopendb” using 128Mb of RAM. The variable db is a handle to the open database. Other arguments can be specified, such as mem_page_size and db_max_connections.

The complete set of arguments to open_database() are as follows:

 
    def open_database(dbname, dictionary, 
            is_disk = False, 
            db_segment_size = 128*1024*1024, 
            cache_segment_size = 16*1024*1024,
            mem_page_size=256,
            disk_page_size=4096, 										
            db_log_type="REDO_LOG",
            disk_max_database_size = 0,
            file_extension_quantum = 4096*1024,
            db_max_connections = 10,
            iot_agent_id = 0):
             

Note the default value for is_disk = False which is appropriate for an in-memory database. For an in-memory database the relevant parameters are described below. For persistent databases there are additional considerations. Please use the following link to view detailed instructions for creating or opening persistent databases.

Memory page size

The mem_page_size argument defines the size of memory pages for conventional memory. The mem_page_size can be calculated to optimize performance and will vary depending on the application dynamics, but as a rule of thumb, page size should be between 80 and 512 bytes; a 128 byte page size is good in most situations.

(Note that for all-in-memory databases disk_page_size will be ignored when is_disk = False.)

(Also note that rtree indexes require larger page sizes. If error codes MCO_ERR_RTREE or MCO_E_DISK_PAGE_POOL_EXHAUSTED are encountered during database transactions, increase the page size in increments until these error codes are remedied.)

Max database connections

The db_max_connection argument specifies the maximum number of connections that will be managed for this database.

Persistent Databases

Please use the following link to view detailed instructions for creating or opening persistent databases.