multiprocessio / datastation

App to easily query, script, and visualize data from every database, file, and API.
https://datastation.multiprocess.io
Other
2.9k stars 112 forks source link

Unable to connect SQL Server LocalDB #305

Open fortunewalla opened 1 year ago

fortunewalla commented 1 year ago

Is there support for MS SQL Server LocalDB?

SQL Server LocalDB Instance : (localdb)\MSSQLLocalDB

So I entered the host as (localdb)\MSSQLLocalDB with pubs as the database. (This hostname works in Excel when connecting using SQL Server connection)

select 1+2;

It gives this error.

Error evaluating panel:
[INFO] 2023-08-20T22:49:28 DataStation Runner (Go) 0.11.0
[INFO] 2023-08-20T22:49:28 Evaling database panel: Untitled panel #1
[INFO] 2023-08-20T22:49:28 Failed to eval: parse "sqlserver://user:pass@(localdb)\\MSSQLLocalDB:1433?database=pubs": invalid character "\\" in host name

BTW it works with another similar software called DatabaseBrowser

image

eatonphil commented 1 year ago

Maybe try replacing (localdb)\MSSQLLocalDB with 127.0.0.1?

fortunewalla commented 1 year ago

Maybe try replacing (localdb)\MSSQLLocalDB with 127.0.0.1?

Thanks for trying to help out but It gives the following error.

Error evaluating panel:
[INFO] 2023-08-22T18:19:13 DataStation Runner (Go) 0.11.0
[INFO] 2023-08-22T18:19:13 Evaling database panel: Untitled panel #1
[INFO] 2023-08-22T18:19:16 Failed to eval: unable to open tcp connection with host '127.0.0.1:1433': dial tcp 127.0.0.1:1433: connectex: No connection could be made because the target machine actively refused it.

This would make it use TCP connection instead of ODBC connection.

As per the original error, it cannot parse the \ slash in the server name properly. I think? 🤔

eatonphil commented 1 year ago

DataStation just passes the connection string along to the underlying library. So you could ask this question in https://github.com/denisenkom/go-mssqldb (the library used for connecting to SQL Server) and maybe they'll know!

fortunewalla commented 1 year ago

hopefully a resolution will be found by someone. 🤞🏼

fortunewalla commented 1 year ago

So as per the suggestion given on this page: https://weblogs.asp.net/jongalloway/sql-force-the-protocol-tcp-named-pipes-etc-in-your-connection-string

I tried with the connection string Server=np:(localdb)\MSSQLLocalDB

It now gives a different error where it parses everything after : as a port number.

Error evaluating panel:
[INFO] 2023-08-27T16:40:05 DataStation Runner (Go) 0.11.0
[INFO] 2023-08-27T16:40:05 Evaling database panel: Untitled panel #1
[INFO] 2023-08-27T16:40:05 Failed to eval: parse "sqlserver://@Server=np:(localdb)\\MSSQLLocalDB?database=pubs": invalid port ":(localdb)\\MSSQLLocalDB" after host

P.S. I'm posting it here also for future use by someone. 😇