db_service#




Classes#

class RootskiDBService#

class rootski.services.database.non_orm.db_service.RootskiDBService(engine: sqlalchemy.engine.base.Engine)[source]#

Bases: object

fetch_adjective_data(word_id)[source]#
  1. Adjective short forms

fetch_noun_data(word_id)[source]#
  1. Declensions

fetch_verb_data(word_id)[source]#
  1. Conjugations

  2. Aspectual Pairs

fetch_word_data(word_id, main_word_type)[source]#
  1. Breakdown

  2. Definitions

  3. Example Sentences

  4. POS specific results i.e. verb, noun, etc.

  5. The word itself

Parameters
  • word_id (int) – id of a word in the “words” table

  • main_word_type (str) – one of [“noun”, “adjective”, “verb”, “particle”, “adverb”, “preposition”, “pronoun”]

Returns

payload-like object of all data to display on word page

Return type

dict

query_definitions(word_id)[source]#

Returns

[
    {
        "word_type": str,
        "definitions": [
            {
                "definition_id": int,
                "def_position": int,              # the definition objs are sorted by def_position asc
                "sub_defs": [
                    {
                        "sub_def_id": int,
                        "sub_def_position": int,  # sub_def objs are sorted by sub_def_position asc
                        "definition": str,
                        "notes": str | None
                    },
                    ...
                ]
            },
            ...
        ]
    },
    ...
]
query_morpheme_breakdown(word_id)[source]#

Returns a breakdown of the following form

[
    {
        'morpheme': 'год',
        'morpheme_id': 294.0,
        'level': 3.0,
        'position': 0,                  # morphemes sorted by position asc
        'type': 'root',
        'family_id': 134,
        'family': 'гож,год,гожд',
        'meanings': [
            {
                'meaning': 'pleasing:1'
            },
            ...
        ]
    },
    ...
]
run_query(query, as_df=False, **kwargs)[source]#
Parameters
  • query (str) – pre-validated SQL query ready to run against db

  • as_df (bool) – return dataframe object if true, otherwise, rows as dictionaries

  • kwargs – parameters to be forwarded to pandas.read_sql_query

Returns

SQL result set (if not as_df) OR pd.DataFrame: SQL result set (if as_df)

Return type

list[dict]