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)
).
Python versions
- 0.8.0: Last Python 3.7 release
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
Built Distribution
File details
Details for the file unihan_db-0.8.0.tar.gz
.
File metadata
- Download URL: unihan_db-0.8.0.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33625437f3e8995464734bdbbe05891c01c93b10db921c16db54d4b2971cef91 |
|
MD5 | 9e0bab19d748e7868e88e53eacc82b99 |
|
BLAKE2b-256 | a96abaaefbbad3d0d7ae92e9ba6835d5a53978431e5e35ed02aba25e1c50fef9 |
File details
Details for the file unihan_db-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: unihan_db-0.8.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b7a9e6ddaf8fbb310d3aed053b3be219d98f0c7f04f35f48c12c3008b25ca19 |
|
MD5 | bb267a23772121bbd60d530a4712aa0c |
|
BLAKE2b-256 | bf903661bdd10c8f0fec4e8d27456c0723d4a231d99f5762bef3ce4404e19b2e |