# `Database`

class mnemosyne.libmnemosyne.database.Database(component_manager, **kwds)

  Interface class describing the functions to be implemented by the actual database classes.

  Apart from the basic interface defined here, depending on the situation a database can also implement functions for logging, statistics and syncing (see SQLite_logging.py, SQLite_statistics.py, SQLite_sync.py).

  abandon()
  add_card(card)
  add_card_type(card_type)
  add_criterion(criterion)
  add_fact(fact)
  add_fact_view(fact_view)
  add_tag(tag)
  add_tag_to_cards_with_internal_ids(tag, _card_ids)
  backup()
  card(id, is_id_internal)
  card_type(id, is_id_internal)
  card_types_in_use()
  cards(sort_key='', limit=-1)
  cards_due_for_ret_rep(now, sort_key='', limit=-1)
  cards_from_fact(fact)

    Return a list of the cards deriving from a fact.

  cards_learn_ahead(now, sort_key='', limit=-1)
  cards_new_memorising(grade, sort_key='', limit=-1)
  cards_to_relearn(grade, sort_key='', limit=-1)
  cards_unseen(sort_key='', limit=-1)
  cards_with_scheduler_data(scheduler_data, sort_key='', limit=-1, max_ret_reps=-1)
  change_user_id(user_id)
  component_type = 'database'
  criteria()
  criterion(id, is_id_internal)
  current_criterion()
  data_dir()

    Returns directory of the database.

  deactivate()
  default_criterion_name = '__DEFAULT__'
  default_name = 'default'
  delete_card(card)
  delete_card_type(card_type)
  delete_criterion(criterion)
  delete_fact(fact)
  delete_fact_view(fact_view)
  delete_tag(tag)
  delete_tag_if_unused(tag)
  display_name()

    Returns bare name of the database, without parent paths and without extension.

  duplicates_for_fact(fact, card_type)

    Return facts with same ‘card_type.unique_fact_keys’ data as ‘fact’.

  fact(id, is_id_internal)
  fact_view(id, is_id_internal)
  get_or_create_tag_with_name(name)
  get_or_create_tags_with_names(names)
  has_card_type_with_id(id)
  has_card_with_id(id)
  has_clone(card_type)
  has_criterion_with_id(id)
  has_fact_view_with_id(id)
  has_fact_with_id(id)
  has_tag_with_id(id)
  is_empty()
  is_in_use(card_type)
  is_loaded()
  is_user_card_type(card_type)
  known_recognition_questions_count_from_card_types_ids(card_type_ids)
  known_recognition_questions_from_card_types_ids(card_type_ids)
  load(path)
  name()

    Returns name of the database, without parent paths, but with extensions.

  new(path)
  path()

    Returns full path of the database.

  recently_memorised_count(max_ret_reps)
  release_connection()

    Release the connection, so that it may be recreated in a separate thread.

  remove_tag_from_cards_with_internal_ids(tag, _card_ids)
  restore(path)
  save(path=None)
  scheduler_data_count(scheduler_data, max_ret_reps=-1)
  set_current_criterion(criterion)
  set_scheduler_data(scheduler_data)
  sorted_card_types()

    Sorts card types so that all the built-in card types appear first, in the order determined by their id, and then all the user card types appear alphabetically.

  suffix = ''
  tag(id, is_id_internal)
  tags()
  tags_from_cards_with_internal_ids(_card_ids)
  unload()
  update_card(card, repetition_only=False)
  update_card_type(card_type)
  update_criterion(criterion)
  update_fact(fact)
  update_fact_view(fact_view)
  update_tag(tag)
  user_id()
  version = ''