Skip to content

Commit

Permalink
!squash
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jun 4, 2023
1 parent 892c70c commit 0fb5ef3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions examples/01_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

bootstrap.bootstrap_unihan(session)

random_row = session.query(Unhn).order_by(func.random()).limit(1).first()
random_row_query = session.query(Unhn).order_by(func.random()).limit(1)

pp = pprint.PrettyPrinter(indent=0)
assert random_row_query is not None

pp.pprint(random_row.to_dict())
random_row = random_row_query.first()

pprint.pprint(bootstrap.to_dict(random_row))
3 changes: 1 addition & 2 deletions src/unihan_db/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ def get_session(engine_url="sqlite:///{user_data_dir}/unihan_db.db"):
engine = create_engine(engine_url)

event.listen(mapper, "after_configured", add_to_dict(Base))
Base.metadata.bind = engine
Base.metadata.create_all()
Base.metadata.create_all(bind=engine)
session_factory = sessionmaker(bind=engine)
session = scoped_session(session_factory)

Expand Down

0 comments on commit 0fb5ef3

Please sign in to comment.