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

sqlalchemy.exc.OperationalError #319

Closed
2 tasks done
imsomdev opened this issue Feb 28, 2024 · 7 comments
Closed
2 tasks done

sqlalchemy.exc.OperationalError #319

imsomdev opened this issue Feb 28, 2024 · 7 comments
Labels

Comments

@imsomdev
Copy link

Things to check first

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

  • 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 imsomdev added the bug label Feb 28, 2024
@agronholm
Copy link
Owner

What do you expect me to do about this?

@imsomdev
Copy link
Author

What do you expect me to do about this?

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

@agronholm
Copy link
Owner

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.

@imsomdev
Copy link
Author

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.

@agronholm
Copy link
Owner

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

@we684123
Copy link

To Future Readers,

If your password contains special characters, please use Percent-encoding for encoding.

Alternatively, you can use the following Python code:

import urllib.parse

# URL Encoding
original_string = "pa$ssw@ord"
encoded_string = urllib.parse.quote(original_string)
print(encoded_string) 

# URL Decoding
decoded_string = urllib.parse.unquote(encoded_string)
print(decoded_string) 

This method ensures that your password is correctly interpreted in URLs.

@agronholm
Copy link
Owner

Closing as obsolete, and probably a non-issue.

@agronholm agronholm closed this as not planned Won't fix, can't repro, duplicate, stale Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants