Quickstart#
Installation#
Assure you have at least python >= 3.7.
$ pip install unihan-db
You can upgrade to the latest release with:
$ pip install --upgrade unihan-db
Developmental releases#
New versions of unihan-db are published to PyPI as alpha, beta, or release candidates. In their
versions you will see notfication like a1
, b1
, and rc1
, respectively. 1.10.0b4
would mean
the 4th beta release of 1.10.0
before general availability.
pip:
$ pip install --upgrade --pre unihan-db
via trunk (can break easily):
pip:
$ pip install -e git+https://github.com/cihai/unihan-db.git#egg=unihan-db
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())
Pythonics#
See also