The simplest way to open a database in Python is to use the
open_database()
method:>>> db = exdb.open_database("myopendb", dict) >>> db <exdb.Database object at 0x100827610> >>>In this example, a database with the name “myopendb” is created. By default, it is opened as an in-memory database, using 128Mb of RAM. The variable
db
is a handle to the open database.To create a database with other parameters, other arguments can be specified:
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)Note that if parameter is_
disk = True
the database is created or opened on persistent media and the corresponding parametersdisk_max_database_size
anddisk_page_size
must be set to appropriate non-zero values. Ifis_disk = True
anddisk_page_size = 0
the eXtremeDB runtime will assign it the default value of 4096. If multiple applications or tasks attempt to assign different disk page sizes for the same database, the runtime returns an error code.To open an existing disk file as a database the database metadata must be identical to that used to create the database. For example if the disk file was created with xSQL, the exact same values for
max_indexes , max_classes, mem_page_size
anddisk_page_size
must be used as were defined in the xSQL configuration file:>>> db = exdb.open_database(dbname=sys.argv[1], dictionary=dict, is_disk=true, max_indexes=1000, max_classes=100, mem_page_size=256, disk_page_size=8*256)SDK sample
samples/python/open
illustrates how to open a simple In-Memory database. The sample also demonstrates how to display runtime information by calling the Database methodGetRunTimeInfo()
. Please build and run the sample application and examine the source code.