sqlacodegen icon indicating copy to clipboard operation
sqlacodegen copied to clipboard

sqlalchemy.exc.OperationalError

Open imsomdev opened this issue 4 months ago • 5 comments

Things to check first

  • [X] I have searched the existing issues and didn't find my bug already reported there

  • [X] I have checked that my bug is still present in the latest release

Sqlacodegen version

sqlacodegen==3.0.0b2

SQLAlchemy version

SQLAlchemy==1.4.51

RDBMS vendor

MSSQL

What happened?

  File "src/pymssql/_pymssql.pyx", line 653, in pymssql._pymssql.connect
sqlalchemy.exc.OperationalError: (pymssql._pymssql.OperationalError) (18456, b"Login failed for user 'sa'.DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (localhost)\n")
(Background on this error at: https://sqlalche.me/e/14/e3q8)

sqlacodegen mssql+pymssql://sql_username:sql_password@server/database giving above error but with postgres it's working fine.

Database schema for reproducing the bug

No response

imsomdev avatar Feb 28 '24 12:02 imsomdev

What do you expect me to do about this?

agronholm avatar Feb 28 '24 13:02 agronholm

What do you expect me to do about this?

I mean, why like this? Am I doing anything wrong?

imsomdev avatar Feb 28 '24 14:02 imsomdev

Well, from the error message if looks like the login failed, so wrong username/password combination. See if you can connect with bare sqlalchemy using the same connection URI.

agronholm avatar Feb 28 '24 14:02 agronholm

Well, from the error message if looks like the login failed, so wrong username/password combination. See if you can connect with bare sqlalchemy using the same connection URI.

No, the password and username combination is correct. But didn't check that with sqlalchemy. Will let you know tomorrow. Thanks.

imsomdev avatar Feb 28 '24 14:02 imsomdev

If your password contains certain special characters, they may need to be escaped.

agronholm avatar Feb 28 '24 14:02 agronholm