Skip to content

Commit

Permalink
add kMandarin table
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jun 5, 2017
1 parent d169338 commit 5ca9413
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf8 - *-

from unihan_db import bootstrap
from unihan_db.tables import Unhn, kDefinition, kCantonese, Base
from unihan_db.tables import Unhn, kDefinition, kCantonese, kMandarin, Base


def test_reflect_db(tmpdb_file, unihan_options, metadata):
Expand Down Expand Up @@ -47,4 +47,11 @@ def test_import_unihan_raw(zip_file, session, engine, unihan_options):
for defi in char['kCantonese']:
c.kCantonese.append(kCantonese(definition=defi))
assert len(c.kCantonese) == len(char['kCantonese'])
if 'kMandarin' in char:
defi = char['kMandarin']
c.kMandarin.append(kMandarin(
hans=defi['zh-Hans'],
hant=defi['zh-Hant'],
))

session.commit()
11 changes: 11 additions & 0 deletions unihan_db/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Unhn(Base):

kDefinition = relationship("kDefinition", back_populates="char")
kCantonese = relationship("kCantonese", back_populates="char")
kMandarin = relationship("kMandarin", back_populates="char")


class kDefinition(Base):
Expand All @@ -61,3 +62,13 @@ class kCantonese(Base):
definition = Column(String(128))

char = relationship("Unhn")


class kMandarin(Base):
__tablename__ = 'kMandarin'
id = Column(Integer, primary_key=True)
char_id = Column(Integer, ForeignKey('Unhn.id'))
hans = Column(String(10))
hant = Column(String(10))

char = relationship("Unhn")

0 comments on commit 5ca9413

Please sign in to comment.