Understand.
Here is the piece of code that does the connection:
 // dbInfo = 
sqlserver://gh:password!655@localhost:7867?database=test_database 
db, err := sql.Open("mssql", dbInfo)
    if err != nil {
        log.Errorf("Could not open database: %s\n %s\n", dbInfo, err.Error())
        return nil, err
    }
    err = db.Ping()
    if err != nil {
        log.Error("db Ping error:", err)
        return nil, err
    }

Thanks

On Thursday, October 15, 2020 at 9:23:10 AM UTC-7 [email protected] wrote:

> I mean the full command that has the connection string in it, most 
> importantly the driver string. Sorry for not putting that as clearly as I 
> could...
>
>   *Joop Kiefte* - Chat @ Spike 
> <https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=q8f5w>
> [image: q8f5w]
>
> On October 15, 2020 at 16:19 GMT, farid sobhany <[email protected]> 
> wrote:
>
>
> The connection works when running the application.
> Here is the connection string (changed sensitive info):
> sqlserver://gh:password!655@localhost:7867?database=test_database  
>
> Thanks
>
> On Thursday, October 15, 2020 at 6:36:11 AM UTC-7 [email protected] wrote:
>
>> Just a hunch, what does your connection string look like?
>>
>>   *Joop Kiefte* - Chat @ Spike 
>> <https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=q87fr> [image: 
>> q87fr]
>>
>> On October 15, 2020 at 13:30 GMT, farid sobhany <[email protected]> 
>> wrote:
>>
>>
>> I have searched the whole application for that import, and I couldn't 
>> find it. I did import it in the test file and still got the same error.
>> On Thursday, October 15, 2020 at 12:43:36 AM UTC-7 [email protected] 
>> wrote:
>>
>>> Maybe you're importing it somewhere else in your main package. In any 
>>> case, adding an anonymous import in one of your _test.go-files should do 
>>> the trick. 
>>>
>>> On 15.10.20 03:53, farid sobhany wrote: 
>>> > I am using database/sql to connect to a Mssql server and it works when 
>>> I 
>>> > run the application. But when I setup a test file and tried to call 
>>> the 
>>> > function that makes the connection and store it in an instance, it 
>>> > complains about "Unknown driver \"mssql\" (forgotten import?)" 
>>> > I am not importing the driver in the main file and it works fine. Why 
>>> > does it complain when running the test funciton? 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "golang-nuts" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> > an email to [email protected] 
>>> > <mailto:[email protected]>. 
>>> > To view this discussion on the web visit 
>>> > 
>>> https://groups.google.com/d/msgid/golang-nuts/e8a43561-551b-44e1-8605-283ce1f064b0n%40googlegroups.com
>>>  
>>> > <
>>> https://groups.google.com/d/msgid/golang-nuts/e8a43561-551b-44e1-8605-283ce1f064b0n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>  
>>>
>>>
>>> -- 
>>> Gregor Best 
>>> [email protected] 
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>>
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/598c16c2-aca1-4cf2-94c7-1733c3cee30fn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/598c16c2-aca1-4cf2-94c7-1733c3cee30fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/a208b607-8d0f-45f4-9308-44a5c91657dfn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/a208b607-8d0f-45f4-9308-44a5c91657dfn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/791cdfd1-2066-42d8-9b3d-72f4a1ee00ffn%40googlegroups.com.

Reply via email to