The Connection class provides the following methods to manage the database Connection, Transactions and Cursors:
close()Close this connection; the connection object becomes invalidStart a database transaction on this connectioncommit()Commit an open transaction on this connectionrollback()Rollback the database changes made in the current transactioncreateBackup(filename, label, type, compression_level, cipher)Create an incremental backup record in the specified filerestoreBackup(filename, label, cipher)Restore the database from an incremental backup in the specified file up to the specified labeldeleteAll(clsDesc)Delete all objects of the class
clsDesc
(the class description, either as a string or the class type taken from the Dictionary object) For example, the following two calls are equivalent:>>>conn.deleteAll(‘myclass’) >>>conn.deleteAll(dict.classes[‘myclass’])new(clsName)Create new object in the database using the schema definition for classclsName
waitEvent(eventId)Start waiting for an asynchronous event specified by argumenteventId
(Normally this is called from a separate event-handler thread)releaseAllEvents()Release all events and stop the event handler threadsremove(obj)Remove an objectobj
from the database. The object argumentobj
must be taken from one of the Cursor operationsfind()
orsearch()
executed on this connectionCreate a cursor for retrieving data on this connectiongetStats()Get database statistics; it returns a dictionary containing keys with the following database information:
TotalPages FreePages PageSizeFor persistent databases it also contains dictionary keys with the disk file statistics:
DataFileSize LogFileSize UsedDatabaseSizegetClassStats(cls)Get class
cls
statistics from the database; iIt returns a dictionary containing the following keys:ObjectsNum VersionsNum CorePages BlobPages CoreSpacegetIndexStats(idx)Get index
idx
statistics from the database; it returns a dictionary containing the following keys:ClassCode Type Label KeysNum PagesNum AvgChainLength – for hash indexes only MaxChainLength - for hash indexes only LevelsNum – for tree indexes only DuplicatesNum - for tree indexes only DiskPagesNumgetDiskCacheInfo()Get disk cache statistics; it returns a dictionary containing the following keys:
connection_cache_hits cache_hits cache_misses allocated_pages used_pages pinned_pages modified_pages dirty_pages copied_pages write_delayed_pages subsequent_readssaveSnapshot(path, saveMetadata=True, saveCRC=True)Perform a snapshot image of the database to a disk file specified by path argumentsdbA Read-Only property specifying the database on which this connection is openedengineA Read-Only property specifying the SQL engine for this connection