-
Notifications
You must be signed in to change notification settings - Fork 563
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
Make SQL_DRIVER_NOPROMPT configurable. #651
Comments
I just fooled around with this a bit. The options for /* Options for SQLDriverConnect */
#define SQL_DRIVER_NOPROMPT 0
#define SQL_DRIVER_COMPLETE 1
#define SQL_DRIVER_PROMPT 2
#define SQL_DRIVER_COMPLETE_REQUIRED 3 If I hack Line 125 in 969ea2c
to specify either pyodbc.pooling = False
conn_str = (
r'DRIVER=ODBC Driver 17 for SQL Server;'
r'SERVER=localhost,49242;'
r'DATABASE=myDb;'
r'Trusted_Connection=no;'
r'UseFMTONLY=Yes;'
)
cnxn = pyodbc.connect(connection_string, autocommit=True) ... I get the error
|
@gordthompson Did you supply a WindowHandle in SQLDriverConnect? |
@v-makouz - No, I just changed the one parameter value to see what would happen. I was sort of hoping that the driver and/or DM would take care of the rest, but apparently there's more to it than that. |
@gordthompson It needs a window handle to generate a dialog box. The following doc has more information, and there is a code sample there that uses the dialog prompt: |
If the win32 extensions for python are installed, you could possibly use |
@soundstripe - That could definitely be a possibility for a standard Python application on Windows. However, pyodbc is a "extension module" written in C/C++ and I have no idea whether it is possible for pyodbc code to detect the window handle of the Python application under which it is running. |
GetDesktopWindow returns the handle to the desktop, not a handle to anything in the process. It's been many years since I used it but it does work. Good suggestion, but since you have a workaround for now, I'm going to mark this as a future item and clear out bugs first. If we get another request, I'll bump the priority. |
Hello. I'm having the same error.
Any possible straight-forward solution? |
The error message tells you what to do. |
@v-chojas I have found the solution, which, interestingly, is not directly related to the error explained. For anyone facing a similar issue, the following command resolved my problem: |
I'm opening this issue primarily as a discussion. In desktop applications (specifically, in Windows apps), ODBC drivers often prompt the user directly for credentials. I noticed that pyodbc is specifying
SQL_DRIVER_NOPROMPT
forSqlDriverConnect
and cannot be made to use those driver prompts.I have already written my own password prompting code as a workaround but would it be a simple change to make this option configurable? Looks like the valid options are constants defined as
SQL_DRIVER_PROMPT, SQL_DRIVER_COMPLETE, SQL_DRIVER_COMPLETE_REQUIRED, or SQL_DRIVER_NOPROMPT
.The text was updated successfully, but these errors were encountered: