Skip to content

Commit

Permalink
Resolve Windows OS encoding bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alptezbasaran committed Jun 20, 2024
1 parent bc71077 commit e8c5064
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/gened/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def init_db() -> None:
db.executescript(f.read())

# App-specific schema in the app's package
with current_app.open_resource('schema.sql', 'r') as f:
db.executescript(f.read())
with current_app.open_resource('schema.sql', 'rb') as f:
db.executescript(f.read().decode('utf-8'))

# Mark all existing migrations as applied (since this is a fresh DB)
for func in _on_init_db_callbacks:
Expand Down
2 changes: 1 addition & 1 deletion src/gened/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _apply_migrations(migrations: Iterable[MigrationDict]) -> None:
def _migration_info(resource: Traversable) -> MigrationDict:
"""Get info on a migration, provided as an importlib.resources resource."""
db = get_db()
with resources.as_file(resource) as path, path.open() as f:
with resources.as_file(resource) as path, path.open(encoding='utf-8') as f:
name = path.name
info: MigrationDict = {
'name': name,
Expand Down

0 comments on commit e8c5064

Please sign in to comment.