Camel.DB¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Camel.DB(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
New in version 2.24.
- classmethod camel_mir_free(record)¶
- Parameters:
record (
Camel.MIRecord
orNone
) – aCamel.MIRecord
Frees the record and all of its associated data.
New in version 2.24.
- classmethod free_sqlized_string(string)¶
-
Frees a string previosuly returned by
Camel.DB.sqlize_string
().New in version 2.24.
- classmethod get_column_ident(hash, index, col_names)¶
- Parameters:
hash ({
object
:object
}) – aGLib.HashTable
index (
int
) – an index to start with, between 0 and ncolscol_names ([
str
]) – column names to traverse
- Returns:
- hash:
- Return type:
(
Camel.DBKnownColumnNames
, hash: {object
:object
})
Traverses column name from index index into an enum
Camel.DBKnownColumnNames
value. The col_names contains ncols columns. First time this is called is created the hash from col_names indexes into the enum, and this is reused for every other call. The function expects that column names are returned always in the same order. When all rows are read the hash table can be freed withGLib.HashTable.destroy
().New in version 3.4.
- classmethod get_column_name(raw_name)¶
- Parameters:
raw_name (
str
) – raw name to find the column name for- Returns:
A corresponding column name in the message info table for the raw_name, or
None
, when there is no corresponding column in the summary.- Return type:
New in version 2.24.
- classmethod new(filename)¶
- Parameters:
filename (
str
) – A filename with the database to open/create- Raises:
- Returns:
A new
Camel.DB
with filename as its database file. Free it withGObject.Object.unref
() when no longer needed.- Return type:
New in version 3.24.
- classmethod release_cache_memory()¶
Instructs sqlite to release its memory, if possible. This can be avoided when CAMEL_SQLITE_FREE_CACHE environment variable is set.
New in version 3.24.
- classmethod sqlize_string(string)¶
- Parameters:
string (
str
) – a string to “sqlize”- Returns:
A newly allocated sqlized string. The returned value should be freed with
Camel.DB.sqlize_string
(), when no longer needed.- Return type:
Converts the string to be usable in the SQLite statements.
New in version 2.24.
- abort_transaction()¶
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Ends an ongoing transaction by ignoring the changes.
New in version 2.24.
- add_to_transaction(query)¶
- Parameters:
query (
str
) – an SQL (SQLite) statement- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Adds a statement to an ongoing transaction.
New in version 2.24.
- begin_transaction()¶
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Begins transaction. End it with
Camel.DB.end_transaction
() orCamel.DB.abort_transaction
().New in version 2.24.
- clear_folder_summary(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Deletes the given folder from the ‘folders’ table and empties its message info table.
New in version 2.24.
- command(stmt)¶
- Parameters:
stmt (
str
) – an SQL (SQLite) statement to execute- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Executes an SQLite command.
New in version 2.24.
- count_deleted_message_info(table_name)¶
- Parameters:
table_name (
str
) – name of the table- Raises:
- Returns:
0 on success, -1 on error
- count:
where to store the resulting count
- Return type:
Counts how many deleted messages is stored in the given table.
New in version 2.24.
- count_junk_message_info(table_name)¶
- Parameters:
table_name (
str
) – name of the table- Raises:
- Returns:
0 on success, -1 on error
- count:
where to store the resulting count
- Return type:
Counts how many junk messages is stored in the given table.
New in version 2.24.
- count_junk_not_deleted_message_info(table_name, count)¶
- Parameters:
- Raises:
- Return type:
- count_message_info(query)¶
- Parameters:
query (
str
) – a COUNT() query- Raises:
- Returns:
0 on success, -1 on error
- count:
the result of the query
- Return type:
Executes a COUNT() query (like “SELECT COUNT(*) FROM table”) and provides the result of it as an unsigned 32-bit integer.
New in version 2.26.
- count_total_message_info(table_name)¶
- Parameters:
table_name (
str
) – name of the table- Raises:
- Returns:
0 on success, -1 on error
- count:
where to store the resulting count
- Return type:
Counts how many messages is stored in the given table.
New in version 2.24.
- count_unread_message_info(table_name)¶
- Parameters:
table_name (
str
) – name of the table- Raises:
- Returns:
0 on success, -1 on error
- count:
where to store the resulting count
- Return type:
Counts how many unread messages is stored in the given table.
New in version 2.24.
- count_visible_message_info(table_name)¶
- Parameters:
table_name (
str
) – name of the table- Raises:
- Returns:
0 on success, -1 on error
- count:
where to store the resulting count
- Return type:
Counts how many visible (not deleted and not junk) messages is stored in the given table.
New in version 2.24.
- count_visible_unread_message_info(table_name)¶
- Parameters:
table_name (
str
) – name of the table- Raises:
- Returns:
0 on success, -1 on error
- count:
where to store the resulting count
- Return type:
Counts how many visible (not deleted and not junk) and unread messages is stored in the given table.
New in version 2.24.
- create_folders_table()¶
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Creates a ‘folders’ table, if it doesn’t exist yet.
New in version 2.24.
- delete_folder(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Deletes the given folder from the ‘folders’ table and also drops its message info table.
New in version 2.24.
- delete_uid(folder_name, uid)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Deletes single mesage info in the given folder with the given UID.
New in version 2.24.
- delete_uids(folder_name, uids)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Deletes a list of message UIDs as one transaction.
New in version 2.24.
- end_transaction()¶
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Ends an ongoing transaction by committing the changes.
New in version 2.24.
- flush_in_memory_transactions(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
0 on success, -1 on error
- Return type:
A pair function for
Camel.DB.start_in_memory_transactions
(), to commit the changes to folder_name and free the in-memory table.New in version 2.26.
- get_folder_deleted_uids(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
An array of the UID-s of the deleted messages in the given folder. Use
Camel.pstring_free
() to free the elements.- Return type:
New in version 2.24.
- get_folder_junk_uids(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
An array of the UID-s of the junk messages in the given folder. Use
Camel.pstring_free
() to free the elements.- Return type:
New in version 2.24.
- get_folder_uids(folder_name, sort_by, collate, hash)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Fills hash with uid->GUINT_TO_POINTER (flag). Use
Camel.pstring_free
() to free the keys of the hash.New in version 2.24.
- maybe_run_maintenance()¶
- Raises:
- Returns:
Whether succeeded.
- Return type:
Runs a self maintenance, which includes vacuum, if necessary.
New in version 3.16.
- prepare_message_info_table(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Prepares message info table for the given folder.
New in version 2.24.
- read_folder_info_record(folder_name)¶
- Parameters:
folder_name (
str
) – full name of the folder- Raises:
- Returns:
0 on success, -1 on error
- record:
- Return type:
(
int
, record:Camel.FIRecord
)
reads folder information for the given folder and stores it into the record.
New in version 2.24.
- read_message_info_record_with_uid(folder_name, uid, user_data, callback)¶
- Parameters:
folder_name (
str
) – full name of the folderuid (
str
) – a message info UID to read the record forcallback (
Camel.DBSelectCB
) – callback to call for the found row
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Selects single message info for the given uid in folder folder_name and calls the callback for it.
New in version 2.24.
- read_message_info_records(folder_name, user_data, callback)¶
- Parameters:
folder_name (
str
) – full name of the foldercallback (
Camel.DBSelectCB
) – callback to call for each found row
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Reads all mesasge info records for the given folder and calls callback for them.
New in version 2.24.
- rename_folder(old_folder_name, new_folder_name)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Renames tables for the old_folder_name to be used with new_folder_name.
New in version 2.24.
- reset_folder_version(folder_name, reset_version)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Sets a version number for the given folder.
New in version 2.28.
- select(stmt, callback, *user_data)¶
- Parameters:
stmt (
str
) – a SELECT statment to executecallback (
Camel.DBSelectCB
) – a callback to call for each row
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Executes a SELECT staement and calls the callback for each selected row.
New in version 2.24.
- set_collate(col, collate, func)¶
- Parameters:
col (
str
) – a column name; currently unusedcollate (
str
) – collation namefunc (
Camel.DBCollate
) – aCamel.DBCollate
collation function
- Return type:
Defines a collation collate, which can be used in SQL (SQLite) statement as a collation function. The func is called when colation is used.
New in version 2.24.
- start_in_memory_transactions()¶
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Creates an in-memory table for a batch transactions. Use
Camel.DB.flush_in_memory_transactions
() to commit the changes and free the in-memory table.New in version 2.26.
- transaction_command(qry_list)¶
- Parameters:
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Runs the list of commands as a single transaction.
New in version 2.24.
- write_folder_info_record(record)¶
- Parameters:
record (
Camel.FIRecord
) – aCamel.FIRecord
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Write the record to the ‘folders’ table.
New in version 2.24.
- write_message_info_record(folder_name, record)¶
- Parameters:
folder_name (
str
) – full name of the folderrecord (
Camel.MIRecord
) – aCamel.MIRecord
- Raises:
- Returns:
0 on success, -1 on error
- Return type:
Write the record to the message info table of the given folder.
New in version 2.24.