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

Error when missing database name in sqlalchemy.create_engine() #66

Open
clach04 opened this issue Aug 26, 2024 · 1 comment
Open

Error when missing database name in sqlalchemy.create_engine() #66

clach04 opened this issue Aug 26, 2024 · 1 comment

Comments

@clach04
Copy link
Member

clach04 commented Aug 26, 2024

It looks like sqlalchemy.create_engine() can be called without a database name, as a quick way to get dialect information (without an actual database connection.

The following fails:

import sqlalchemy

sqlalchemy.create_engine('ingres://')

With error:

Traceback (most recent call last):
  File "C:\code\py\sqlalchemy-ingres\create_engine_bug_no_dbname.py", line 3, in <module>
    sqlalchemy.create_engine('ingres://')
  File "<string>", line 2, in create_engine
  File "C:\code\py\sqlalchemy-ingres\py312venv\Lib\site-packages\sqlalchemy\util\deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
  File "C:\code\py\sqlalchemy-ingres\py312venv\Lib\site-packages\sqlalchemy\engine\create.py", line 615, in create_engine
    (cargs_tup, cparams) = dialect.create_connect_args(u)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\code\py\sqlalchemy-ingres\lib\sqlalchemy_ingres\pyodbc.py", line 56, in create_connect_args
    conn_list.append('Database=' + url.database)
                     ~~~~~~~~~~~~^~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str
@clach04
Copy link
Member Author

clach04 commented Aug 26, 2024

Briefly toyed with:

conn_list.append('Database=' + (url.database or 'database_not_specified'))

as one option, rejected in the end.

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

5 participants
@clach04 and others