SQLAlchemy models for UNIHAN CJK database
Project description
unihan-db ·

Database SQLAlchemy models for UNIHAN. Part of the cihai project. Powered by unihan-etl. See also: libUnihan.
By default, unihan-db creates a SQLite database in an XDG data directory. You can specify a custom database destination by passing a database url into get_session.
Example usage
#!/usr/bin/env python
import pprint
from sqlalchemy.sql.expression import func
from unihan_db import bootstrap
from unihan_db.tables import Unhn
session = bootstrap.get_session()
bootstrap.bootstrap_unihan(session)
random_row = session.query(Unhn).order_by(
func.random()
).limit(1).first()
pp = pprint.PrettyPrinter(indent=0)
pp.pprint(random_row.to_dict())
Run:
$ ./examples/01_bootstrap.py
Output:
{'char': '鎷',
'kCantonese': [{'char_id': '鎷', 'definition': 'maa5', 'id': 24035}],
'kDefinition': [],
'kHanYu': [{'char_id': '鎷',
'id': 24014,
'locations': [{'character': 5,
'generic_indice_id': 24014,
'generic_reading_id': None,
'id': 42170,
'page': 4237,
'virtual': 0,
'volume': 6}],
'type': 'kHanYu'}],
'kHanyuPinyin': [{'char_id': '鎷',
'id': 18090,
'locations': [{'character': 5,
'generic_indice_id': None,
'generic_reading_id': 18090,
'id': 42169,
'page': 4237,
'virtual': 0,
'volume': 6}],
'readings': [{'generic_reading_id': 18090,
'id': 26695,
'reading': 'mǎ'}],
'type': 'kHanyuPinyin'}],
'kMandarin': [{'char_id': '鎷', 'hans': 'mǎ', 'hant': 'mǎ', 'id': 23486}],
'ucn': 'U+93B7'}
Developing
$ git clone https://github.com/cihai/unihan-etl.git
$ cd unihan-etl
Bootstrap your environment and learn more about contributing. We use the same conventions / tools across all cihai projects: pytest
, sphinx
, flake8
, mypy
, black
, isort
, tmuxp
, and file watcher helpers (e.g. entr(1)
).
More information
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unihan_db-0.7.1.tar.gz
(39.9 kB
view hashes)
Built Distribution
unihan_db-0.7.1-py3-none-any.whl
(10.4 kB
view hashes)
Close
Hashes for unihan_db-0.7.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1579860d5797075fcfd0f0fcbe349cd2e96f4f05e0f8fe39a016e95d0c6ad85 |
|
MD5 | ab5a6391ac0a2f491a912e19d43e9fc5 |
|
BLAKE2b-256 | 8149c05516cba7484f6bd4c86b42a3180d6823fbe4d03efea2fd75b8726bdef5 |