to_sqlite.py
Converts all or desired JSON data generated by Scribe-Data into SQLite databases.
- scribe_data.cli.convert.to_sqlite.create_table(cursor: Cursor, identifier_case: str, data_type: str, cols: list[str]) None[source]
Create a table in the language database.
- Parameters:
- cursorsqlite3.Cursor
A sqlite3 cursor.
- identifier_casestr
Either “camel” or “snake” to determine column naming.
- data_typestr
The name of the table to be created.
- colslist of str
The names of columns for the new table.
- scribe_data.cli.convert.to_sqlite.table_insert(cursor: Cursor, data_type: str, keys: list) None[source]
Insert a row into a language database table.
- Parameters:
- cursorsqlite3.Cursor
A sqlite3 cursor.
- data_typestr
The name of the table to be inserted into.
- keyslist of any
The values to be inserted into the table row.
- scribe_data.cli.convert.to_sqlite.translations_to_sqlite(language_data_type_dict: dict, current_languages: list, identifier_case: str = 'snake', input_file: Path = PosixPath('scribe_data_json_export'), output_file: Path = PosixPath('scribe_data_sqlite_export'), overwrite: bool = False) None[source]
Derive translations to create a TranslationData.sqlite file that contains a table for each language.
- Parameters:
- language_data_type_dictdict
A dictionary specifying the data types for each language.
- current_languageslist
A list of current languages.
- identifier_casestr, optional
The identifier case. Default is “snake”.
- input_filestr, optional, default=DEFAULT_JSON_EXPORT_DIR
The input JSON export directory.
- output_filestr, optional, default=DEFAULT_SQLITE_EXPORT_DIR
The output SQLite export directory.
- overwritebool, optional
If True, existing SQLite files will be overwritten without prompting.
- scribe_data.cli.convert.to_sqlite.wiktionary_translations_to_sqlite(language, identifier_case='snake', input_file=PosixPath('scribe_data_json_export'), output_file=PosixPath('scribe_data_sqlite_export'), overwrite: bool = False)[source]
Convert Wiktionary _translations_from_.json files into SQLite tables.
- Each JSON file has the structure:
{ word: { word_type: { order: { description, translation } } } }
- The resulting SQLite table uses columns:
word | word_type | order | description | translation
- Parameters:
- languagestr
The language whose directory contains the translation JSON files.
- identifier_casestr, optional
Either “camel” or “snake” to determine column naming. Default is “snake”.
- input_filestr, optional, default=DEFAULT_JSON_EXPORT_DIR
The input JSON export directory.
- output_filestr, optional, default=DEFAULT_SQLITE_EXPORT_DIR
The output SQLite export directory.
- overwritebool, optional
If True, existing SQLite files will be overwritten without prompting.
- scribe_data.cli.convert.to_sqlite.convert_to_sqlite(languages: list[str] | None = None, specific_tables: str | list[str] | None = None, identifier_case: str = 'camel', input_file: Path = PosixPath('scribe_data_json_export'), output_file: Path = PosixPath('scribe_data_sqlite_export'), overwrite: bool = False) None[source]
Create SQLite databases from JSON data.
- Parameters:
- languagesOptional[List[str]]
The languages to process. If None, use all available languages.
- specific_tablesOptional[Union[str, List[str]]]
The specific tables to process. If None, process all tables.
- identifier_casestr, optional, default=’camel’
Format of the identifiers (“camel” or “snake”). Defaults to “camel”.
- input_filestr, optional, default=DEFAULT_JSON_EXPORT_DIR
The input JSON export directory.
- output_filestr, optional, default=DEFAULT_SQLITE_EXPORT_DIR
The output SQLite export directory.
- overwritebool, optional
If set to True, existing SQLite files will be overwritten without prompting.