inline_sql_syntax icon indicating copy to clipboard operation
inline_sql_syntax copied to clipboard

Can't connect to DB

Open jontobonto opened this issue 2 years ago • 3 comments

I have put my database credentials in the settings.json, but it does not seem to connect to my database. Is there any Log?

jontobonto avatar Apr 06 '22 15:04 jontobonto

Hi, thanks for reporting, @NarmyOnDiscord! Added rudimentary logging in output panel (Inline SQL tab) in v2.10.3.

Might be related - one upstream issue with sql-lint I observed is that if the first keyword in SQL string is not one of the predefined SQL keywords - it does not run EXPLAIN query on real database. Go example:

package main

func main() {
	query := `--sql
sselect * from book where price = 11;
`
}

sselect is misspelled and the first keyword - sql-lint reports no errors and does not run EXPLAIN.

barklan avatar Apr 08 '22 20:04 barklan

I'm running into the same issue, didn't know whether I should have created a new issue or comment on this one.

My setup uses WSL2 on Windows 11, this extension is being installed on my WSL's .vscode-server/extensions directory by default.

In my workspace settings.json I have:

{
  "inlineSQL.dbDriver": "postgres",
  "inlineSQL.dbHost": "localhost",
  "inlineSQL.dbPort": 5432,
  "inlineSQL.dbUser": "docker",
  "inlineSQL.dbPassword": "docker",
  "inlineSQL.enableDBIntegration": true,
  "inlineSQL.lintSQLFiles": false
}

In my Javascript code I write:

const s = `--sql
  SELECT yo FORM order WHERE order_id="hello"
`;

Which I know is incorrect. The correct form should be:

SELECT * FROM orders WHERE id=1;

But instead, all I get in Inline SQL's Output is this:

inline SQL activated
watching active editors
2022-04-20T19:39:51.141Z: document saved, refreshing diagnostics
linting sql: --sql
          SELECT yo FORM order WHERE order_id="hello"
        
linting sql using live database
0 errors found
2022-04-20T19:39:51.146Z: 1 SQL strings found and linted

Is there anything that I might be doing wrong that prevents the linting from working?

UPDATE: I think I had to give it a little more time or reload my VS Code window. It seems to be working now to some extent. The only issue is that it is showing that my valid sql relations are not valid! I noticed that I was not able to specify the name of the exact database that I want the extension to connect to, so could this be the reason I'm experiencing this problem? Because I have 4 databases under the same psql connection port.

sepsol avatar Apr 20 '22 19:04 sepsol

omg, this has taken me on emotional rollecoaster when I discovered the integration and when I found out that there is no way to indicate database name in like 30 seconds after. 😂

punkuotukas avatar Sep 13 '24 15:09 punkuotukas