# Create/Open Persistent Databases in Python

> To create or open a persistent database, the application ...

> ## Parameter Settings

> Please refer to the general guidelines discussed in the Creating Databases page for determining the proper values for `MemPageSize`, `DiskPageSize`, `MaxConnections`, `MaxDiskDatabaseSize` and `LogType`.

> ### Log Type and Transaction Commit Policy

> Applications set the `DatabaseParameters.LogType` to `RedoLog, UndoLog` or `NoLog` for the Database method `open()`. Depending on the log type selected, the additional Database.Parameters property `RedoLogLimit` or `DelayedCommitThreshold` can be set. (Please see the Persistent Database I/O page for detailed explanations.)

> Note that if the `NoLog` log type is selected, the application can explicitly force the cache to be flushed to the media with the Connection method `diskFlush()`.

> ## Memory Device Specification

> As explained in the Python memory devices page, applications using persistent databases must specify at least four memory devices:

> - dictionary and metadata, and possible transient class data: a private or shared memory device
> - persistent data storage: a file, multifile or raid device
> - persistent data cache: a private or shared memory device
> - transaction log: a file, multifile or raid device

> To specify these devices, the application instantiates a tuple of devices and passes this to the `open_database()` call. For example, the following code snippet defines memory for an in-memory or persistent database, then creates the database:

>         if self.disk:

>             devices = (self.exdb.fileDevice(self.exdb.Device.Data, "open_db.dbs"),
>                 self.exdb.fileDevice(self.exdb.Device.TransactionLog, "open_db.log"),
>                 self.exdb.privateMemoryDevice(self.exdb.Device.Data, 4*1024*1024),
>                 self.exdb.privateMemoryDevice(self.exdb.Device.DiskCache, 16*1024*1024)
>             )

>         else:
>             devices = ( self.exdb.privateMemoryDevice(self.exdb.Device.Data, 4 * 1024*1024),  )

>         self.db = self.exdb.open_database(dbname='opendb', dictionary=dict, is_disk=self.disk, devices=devices);

> Note that in order to open an existing persistent database, the application must specify the same `open_database()` parameters that were used to create the database.