unihan-db


Nameunihan-db JSON
Version 0.15.0 PyPI version JSON
download
home_pagehttps://unihan-db.git-pull.com
SummarySQLAlchemy models for UNIHAN CJK database
upload_time2024-04-01 10:32:54
maintainerNone
docs_urlNone
authorTony Narlock
requires_python<4.0,>=3.8
licenseMIT
keywords unihan sqlalchemy cjk chinese japanese sql database
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # unihan-db &middot; [![Python Package](https://img.shields.io/pypi/v/unihan-db.svg)](https://pypi.org/project/unihan-db/) [![License](https://img.shields.io/github/license/cihai/unihan-db.svg)](https://github.com/cihai/unihan-db/blob/master/LICENSE) [![Code Coverage](https://codecov.io/gh/cihai/unihan-db/branch/master/graph/badge.svg)](https://codecov.io/gh/cihai/unihan-db)

Database [SQLAlchemy](https://www.sqlalchemy.org/) models for
[UNIHAN](http://www.unicode.org/charts/unihan.html). Part of the [cihai](https://cihai.git-pull.com)
project. Powered by [unihan-etl](https://unihan-etl.git-pull.com). See also:
[libUnihan](http://libunihan.sourceforge.net/).

By default, unihan-db creates a SQLite database in an
[XDG data directory](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html). You
can specify a custom database destination by passing a database url into
[get_session](http://unihan-db.git-pull.com/api.html#unihan_db.bootstrap.get_session).

## Example usage

```python
#!/usr/bin/env python
"""Example for bootstrapping UNIHAN DB and print out a row."""
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_query = session.query(Unhn).order_by(func.random()).limit(1)

assert random_row_query is not None

random_row = random_row_query.first()

pprint.pprint(bootstrap.to_dict(random_row))

pprint.pprint(random_row.to_dict())  # type:ignore
```

Run:

    $ ./examples/01_bootstrap.py

Output:

```python
{'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

```console
$ git clone https://github.com/cihai/unihan-etl.git
```

```console
$ cd unihan-etl
```

[Bootstrap your environment and learn more about contributing](https://cihai.git-pull.com/contributing/). We use the same conventions / tools across all cihai projects: `pytest`, `sphinx`, `mypy`, `ruff`, `tmuxp`, and file watcher helpers (e.g. `entr(1)`).

## Python versions

- 0.8.0:
  - Last Python 3.7 release
  - Last SQLAlchemy 1.3 release

## More information

[![Docs](https://github.com/cihai/unihan-db/workflows/docs/badge.svg)](https://unihan-db.git-pull.com/)
[![Build Status](https://github.com/cihai/unihan-db/workflows/tests/badge.svg)](https://github.com/cihai/unihan-db/actions?query=workflow%3A%22tests%22)


            

Raw data

            {
    "_id": null,
    "home_page": "https://unihan-db.git-pull.com",
    "name": "unihan-db",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "unihan, sqlalchemy, cjk, chinese, japanese, sql, database",
    "author": "Tony Narlock",
    "author_email": "tony@git-pull.com",
    "download_url": "https://files.pythonhosted.org/packages/82/40/822285277170c6f4e0885510116ef0d64700899b4fa4655e48dfe4425617/unihan_db-0.15.0.tar.gz",
    "platform": null,
    "description": "# unihan-db &middot; [![Python Package](https://img.shields.io/pypi/v/unihan-db.svg)](https://pypi.org/project/unihan-db/) [![License](https://img.shields.io/github/license/cihai/unihan-db.svg)](https://github.com/cihai/unihan-db/blob/master/LICENSE) [![Code Coverage](https://codecov.io/gh/cihai/unihan-db/branch/master/graph/badge.svg)](https://codecov.io/gh/cihai/unihan-db)\n\nDatabase [SQLAlchemy](https://www.sqlalchemy.org/) models for\n[UNIHAN](http://www.unicode.org/charts/unihan.html). Part of the [cihai](https://cihai.git-pull.com)\nproject. Powered by [unihan-etl](https://unihan-etl.git-pull.com). See also:\n[libUnihan](http://libunihan.sourceforge.net/).\n\nBy default, unihan-db creates a SQLite database in an\n[XDG data directory](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html). You\ncan specify a custom database destination by passing a database url into\n[get_session](http://unihan-db.git-pull.com/api.html#unihan_db.bootstrap.get_session).\n\n## Example usage\n\n```python\n#!/usr/bin/env python\n\"\"\"Example for bootstrapping UNIHAN DB and print out a row.\"\"\"\nimport pprint\n\nfrom sqlalchemy.sql.expression import func\n\nfrom unihan_db import bootstrap\nfrom unihan_db.tables import Unhn\n\nsession = bootstrap.get_session()\n\nbootstrap.bootstrap_unihan(session)\n\nrandom_row_query = session.query(Unhn).order_by(func.random()).limit(1)\n\nassert random_row_query is not None\n\nrandom_row = random_row_query.first()\n\npprint.pprint(bootstrap.to_dict(random_row))\n\npprint.pprint(random_row.to_dict())  # type:ignore\n```\n\nRun:\n\n    $ ./examples/01_bootstrap.py\n\nOutput:\n\n```python\n{'char': '\u93b7',\n'kCantonese': [{'char_id': '\u93b7', 'definition': 'maa5', 'id': 24035}],\n'kDefinition': [],\n'kHanYu': [{'char_id': '\u93b7',\n          'id': 24014,\n          'locations': [{'character': 5,\n                       'generic_indice_id': 24014,\n                       'generic_reading_id': None,\n                       'id': 42170,\n                       'page': 4237,\n                       'virtual': 0,\n                       'volume': 6}],\n          'type': 'kHanYu'}],\n'kHanyuPinyin': [{'char_id': '\u93b7',\n                'id': 18090,\n                'locations': [{'character': 5,\n                             'generic_indice_id': None,\n                             'generic_reading_id': 18090,\n                             'id': 42169,\n                             'page': 4237,\n                             'virtual': 0,\n                             'volume': 6}],\n                'readings': [{'generic_reading_id': 18090,\n                            'id': 26695,\n                            'reading': 'm\u01ce'}],\n                'type': 'kHanyuPinyin'}],\n'kMandarin': [{'char_id': '\u93b7', 'hans': 'm\u01ce', 'hant': 'm\u01ce', 'id': 23486}],\n'ucn': 'U+93B7'}\n```\n\n## Developing\n\n```console\n$ git clone https://github.com/cihai/unihan-etl.git\n```\n\n```console\n$ cd unihan-etl\n```\n\n[Bootstrap your environment and learn more about contributing](https://cihai.git-pull.com/contributing/). We use the same conventions / tools across all cihai projects: `pytest`, `sphinx`, `mypy`, `ruff`, `tmuxp`, and file watcher helpers (e.g. `entr(1)`).\n\n## Python versions\n\n- 0.8.0:\n  - Last Python 3.7 release\n  - Last SQLAlchemy 1.3 release\n\n## More information\n\n[![Docs](https://github.com/cihai/unihan-db/workflows/docs/badge.svg)](https://unihan-db.git-pull.com/)\n[![Build Status](https://github.com/cihai/unihan-db/workflows/tests/badge.svg)](https://github.com/cihai/unihan-db/actions?query=workflow%3A%22tests%22)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "SQLAlchemy models for UNIHAN CJK database",
    "version": "0.15.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/cihai/unihan-db/issues",
        "Documentation": "https://unihan-db.git-pull.com",
        "Homepage": "https://unihan-db.git-pull.com",
        "Release notes": "https://github.com/cihai/unihan-db/blob/master/CHANGES",
        "Repository": "https://github.com/cihai/unihan-db"
    },
    "split_keywords": [
        "unihan",
        " sqlalchemy",
        " cjk",
        " chinese",
        " japanese",
        " sql",
        " database"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44cb77916aaad0d04839355227214e586787473807048e66d111cf33c89960c2",
                "md5": "5cbd9f9f82653a85bde58575b8f3f099",
                "sha256": "ff7259cfd0eafc747d2d67d2c375f946c6765daca1817473d19cfddade57a55e"
            },
            "downloads": -1,
            "filename": "unihan_db-0.15.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5cbd9f9f82653a85bde58575b8f3f099",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 11788,
            "upload_time": "2024-04-01T10:32:52",
            "upload_time_iso_8601": "2024-04-01T10:32:52.391768Z",
            "url": "https://files.pythonhosted.org/packages/44/cb/77916aaad0d04839355227214e586787473807048e66d111cf33c89960c2/unihan_db-0.15.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8240822285277170c6f4e0885510116ef0d64700899b4fa4655e48dfe4425617",
                "md5": "9df3c61289d068c8f6fc214f15a33b34",
                "sha256": "f3c02c2d35c93d2d86755f2f4175d7eb90cb6a05eae2d8fdc40cb31caa351ec4"
            },
            "downloads": -1,
            "filename": "unihan_db-0.15.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9df3c61289d068c8f6fc214f15a33b34",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 40823,
            "upload_time": "2024-04-01T10:32:54",
            "upload_time_iso_8601": "2024-04-01T10:32:54.102148Z",
            "url": "https://files.pythonhosted.org/packages/82/40/822285277170c6f4e0885510116ef0d64700899b4fa4655e48dfe4425617/unihan_db-0.15.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-01 10:32:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cihai",
    "github_project": "unihan-db",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "unihan-db"
}
        
Elapsed time: 0.27752s