Camel.DB

g Camel.DB Camel.DB GObject.Object GObject.Object GObject.Object->Camel.DB

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

camel_mir_free (record)

class

error_quark ()

class

free_sqlized_string (string)

class

get_column_ident (hash, index, col_names)

class

get_column_name (raw_name)

class

new (filename)

class

release_cache_memory ()

class

sqlize_string (string)

abort_transaction ()

add_to_transaction (query)

begin_transaction ()

clear_folder_summary (folder_name)

command (stmt)

count_deleted_message_info (table_name)

count_junk_message_info (table_name)

count_junk_not_deleted_message_info (table_name, count)

count_message_info (query)

count_total_message_info (table_name)

count_unread_message_info (table_name)

count_visible_message_info (table_name)

count_visible_unread_message_info (table_name)

create_folders_table ()

delete_folder (folder_name)

delete_uid (folder_name, uid)

delete_uids (folder_name, uids)

end_transaction ()

flush_in_memory_transactions (folder_name)

get_filename ()

get_folder_deleted_uids (folder_name)

get_folder_junk_uids (folder_name)

get_folder_uids (folder_name, sort_by, collate, hash)

maybe_run_maintenance ()

prepare_message_info_table (folder_name)

read_folder_info_record (folder_name)

read_message_info_record_with_uid (folder_name, uid, user_data, callback)

read_message_info_records (folder_name, user_data, callback)

rename_folder (old_folder_name, new_folder_name)

reset_folder_version (folder_name, reset_version)

select (stmt, callback, *user_data)

set_collate (col, collate, func)

start_in_memory_transactions ()

transaction_command (qry_list)

write_folder_info_record (record)

write_message_info_record (folder_name, record)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Camel.DB(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Camel.DBClass

New in version 2.24.

classmethod camel_mir_free(record)
Parameters:

record (Camel.MIRecord or None) – a Camel.MIRecord

Frees the record and all of its associated data.

New in version 2.24.

classmethod error_quark()
Return type:

int

classmethod free_sqlized_string(string)
Parameters:

string (str or None) – a string to free

Frees a string previosuly returned by Camel.DB.sqlize_string().

New in version 2.24.

classmethod get_column_ident(hash, index, col_names)
Parameters:
Returns:

hash:

a GLib.HashTable

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 with GLib.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:

str or None

New in version 2.24.

classmethod new(filename)
Parameters:

filename (str) – A filename with the database to open/create

Raises:

GLib.Error

Returns:

A new Camel.DB with filename as its database file. Free it with GObject.Object.unref() when no longer needed.

Return type:

Camel.DB

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:

str

Converts the string to be usable in the SQLite statements.

New in version 2.24.

abort_transaction()
Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Adds a statement to an ongoing transaction.

New in version 2.24.

begin_transaction()
Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Begins transaction. End it with Camel.DB.end_transaction() or Camel.DB.abort_transaction().

New in version 2.24.

clear_folder_summary(folder_name)
Parameters:

folder_name (str) – full name of the folder

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Executes an SQLite command.

New in version 2.24.

count_deleted_message_info(table_name)
Parameters:

table_name (str) – name of the table

Raises:

GLib.Error

Returns:

0 on success, -1 on error

count:

where to store the resulting count

Return type:

(int, count: int)

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:

GLib.Error

Returns:

0 on success, -1 on error

count:

where to store the resulting count

Return type:

(int, count: int)

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:
  • table_name (str) –

  • count (int) –

Raises:

GLib.Error

Return type:

int

count_message_info(query)
Parameters:

query (str) – a COUNT() query

Raises:

GLib.Error

Returns:

0 on success, -1 on error

count:

the result of the query

Return type:

(int, count: int)

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:

GLib.Error

Returns:

0 on success, -1 on error

count:

where to store the resulting count

Return type:

(int, count: int)

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:

GLib.Error

Returns:

0 on success, -1 on error

count:

where to store the resulting count

Return type:

(int, count: int)

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:

GLib.Error

Returns:

0 on success, -1 on error

count:

where to store the resulting count

Return type:

(int, count: int)

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:

GLib.Error

Returns:

0 on success, -1 on error

count:

where to store the resulting count

Return type:

(int, count: int)

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:
  • folder_name (str) – full name of the folder

  • uid (str) – a message info UID to delete

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Deletes single mesage info in the given folder with the given UID.

New in version 2.24.

delete_uids(folder_name, uids)
Parameters:
  • folder_name (str) – full name of the folder

  • uids ([str]) – A GLib.List of uids

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Deletes a list of message UIDs as one transaction.

New in version 2.24.

end_transaction()
Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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_filename()
Returns:

A filename associated with self.

Return type:

str

New in version 3.24.

get_folder_deleted_uids(folder_name)
Parameters:

folder_name (str) – full name of the folder

Raises:

GLib.Error

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:

[str] or None

New in version 2.24.

get_folder_junk_uids(folder_name)
Parameters:

folder_name (str) – full name of the folder

Raises:

GLib.Error

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:

[str] or None

New in version 2.24.

get_folder_uids(folder_name, sort_by, collate, hash)
Parameters:
  • folder_name (str) – full name of the folder

  • sort_by (str or None) – optional ORDER BY clause (without the “ORDER BY” prefix)

  • collate (str or None) – optional collate function name to use

  • hash ({str: int}) – a hash table to fill

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

GLib.Error

Returns:

Whether succeeded.

Return type:

bool

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

GLib.Error

Returns:

0 on success, -1 on error

record:

a Camel.FIRecord

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 folder

  • uid (str) – a message info UID to read the record for

  • user_data (object or None) – user data of the callback

  • callback (Camel.DBSelectCB) – callback to call for the found row

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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 folder

  • user_data (object or None) – user data for the callback

  • callback (Camel.DBSelectCB) – callback to call for each found row

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:
  • old_folder_name (str) – full name of the existing folder

  • new_folder_name (str) – full name of the folder to rename it to

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:
  • folder_name (str) – full name of the folder

  • reset_version (int) – version number to set

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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 execute

  • callback (Camel.DBSelectCB) – a callback to call for each row

  • user_data (object or None) – user data for the callback

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Executes a SELECT staement and calls the callback for each selected row.

New in version 2.24.

set_collate(col, collate, func)
Parameters:
Return type:

int

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:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

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:

qry_list ([str]) – A GLib.List of querries

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Runs the list of commands as a single transaction.

New in version 2.24.

write_folder_info_record(record)
Parameters:

record (Camel.FIRecord) – a Camel.FIRecord

Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Write the record to the ‘folders’ table.

New in version 2.24.

write_message_info_record(folder_name, record)
Parameters:
Raises:

GLib.Error

Returns:

0 on success, -1 on error

Return type:

int

Write the record to the message info table of the given folder.

New in version 2.24.