Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Friendlier error message than TypeError #26

Open
iaindillingham opened this issue Oct 5, 2022 · 0 comments
Open

Friendlier error message than TypeError #26

iaindillingham opened this issue Oct 5, 2022 · 0 comments

Comments

@iaindillingham
Copy link
Member

When neither --dsn is passed nor DATABASE_URL is set, SQL Runner prints a stack trace:

Running actions: query

jobrunner.run loop started
query: Copying in code from /Users/iaindillingham/Code/opensafely/tpp-database-schema
query: Preparing
query: Executing
query: Logs written to: /Users/iaindillingham/Code/opensafely/tpp-database-schema/metadata/query.log
query: Finalizing
query: Job exited with error code 1
query: Cleaning up container and volume

=> query
   Job exited with error code 1

   log file: metadata/query.log
   outputs:
     (no outputs)

   logs:

     Traceback (most recent call last):
       File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
         return _run_code(code, main_globals, None,
       File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
         exec(code, run_globals)
       File "/app/sqlrunner/__main__.py", line 9, in <module>
         results = main.run_sql(dsn=args.dsn, sql_query=sql_query)
       File "/app/sqlrunner/main.py", line 51, in run_sql
         database=parsed_dsn.path.strip("/"),
     TypeError: a bytes-like object is required, not 'str'

parsed_dsn is an instance of ParseResultBytes rather than ParseResult because dsn was None:

parsed_dsn = parse.urlparse(dsn)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant