So, it seems that there are two problems: (1) the connection fails (even
though it works with pyodbc) and (2) retrieving the diagnostic information
after the error hangs with the MS driver. I don't see an obvious reason for
either problem, but I have two thoughts.

Does your connection string have any non-ASCII characters? A difference in
string conversion is one of the few things I can imagine distinguishing
odbc-driver-connect's behavior from pyodbc, since IIUC both just pass the
connection string to SQLDriverConnect without any processing. Also,
double-check backslashes.

It looks like you're using Racket CS. Could you try the program with Racket
BC too? It's possible that there's some difference in the FFI's behavior
between the two versions that the db library is not accounting for.

Ryan


On Sat, Sep 19, 2020 at 10:06 PM Jin-Ho King <jinho.k...@gmail.com> wrote:

> Hi Ryan, thanks so much for your suggestions. Here is the output from
> running your program with my original connection string, which works in
> python using pyodbc:
>
> Allocating env handle... done: 0
> 0
> Setting ODBC version... done: 0
> 0
> Allocating db handle... done: 0
> 0
> Connecting... done: -1
>
>
> This is where it hangs.
>
> Based on your suggestions about trying different drivers, I tried
> switching drivers from the "ODBC Driver 17 for SQL Server” that I had been
> using to the FreeTDS driver the example in your program uses. I was able to
> successfully connect using the FreeTDS driver in python using pyodbc. Using
> the same connection string, I ran your program again. This time, running
> your program didn't hang, but the output was not promising either:
>
> Allocating env handle... done: 0
> 0
> Setting ODBC version... done: 0
> 0
> Allocating db handle... done: 0
> 0
> Connecting... done: -1
> odbc-driver-connect:
>   SQLSTATE:
>   context...:
>    .../generic/interfaces.rkt:170:0: raise-sql-error
>    .../odbc/connection.rkt:781:0: handle-status*
>    call-with-values
>    call-in-empty-metacontinuation-frame
>    body of "/Users/jinho/git/eoddata/test-odbc.rkt"
>    temp35_0
>    run-module-instance!
>    perform-require!
>    namespace-require+
>    proc
>    call-in-empty-metacontinuation-frame
>    thunk_10
>    call-in-empty-metacontinuation-frame
>    call-with-empty-metacontinuation-frame-for-swap
>
>
> I also confirmed using odbc-driver-connect directly that no connection is
> actually made. Do you have any other suggestions? Thanks again!
>
>
> --
> "Ad astra per alia porci"
>
> On Sep 19, 2020, at 8:12 AM, Ryan Culpepper <rmculpepp...@gmail.com>
> wrote:
>
> The last time I tested connecting to MS SQL Server on Windows (several
> years ago), I think I was able to connect using some drivers but not
> others. I was simultaneously trying to figure out authentication and the
> connection string format, so once I got a working configuration I stopped
> investigating. Lately I've been testing using the Docker image on Linux.
>
> I've attached a program you can run to find out where the connection
> process hangs. If you can report the results of running the program that
> should help narrow down the problem.
>
> Ryan
>
>
> On Sat, Sep 19, 2020 at 12:25 AM Jin-Ho King <jinho.k...@gmail.com> wrote:
>
>> Does anyone have experience using Racket to query a MS SQL Server? I'm
>> attempting to use the db-lib package (https://docs.racket-lang.org/db/)
>> and odbc-driver-connect, but running the method just hangs, with no
>> feedback. By contrast, using the same connection string, I can successfully
>> connect using python and pyodbc.
>>
>> Any suggestions or tips would be appreciated!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/58e03456-b76e-4212-a170-82e1fc4fb178n%40googlegroups.com
>> <https://groups.google.com/d/msgid/racket-users/58e03456-b76e-4212-a170-82e1fc4fb178n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> <test-odbc.rkt>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CANy33qkuK%2B%2Beg8_vZT0bE5NfvzXxB52uGzOcOWumA7DK4Zfu-Q%40mail.gmail.com.

Reply via email to