Skip to content
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

Can't connect to DB #9

Open
jontobonto opened this issue Apr 6, 2022 · 3 comments
Open

Can't connect to DB #9

jontobonto opened this issue Apr 6, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jontobonto
Copy link

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

@barklan barklan self-assigned this Apr 8, 2022
@barklan barklan added the bug Something isn't working label Apr 8, 2022
@barklan
Copy link
Owner

barklan commented Apr 8, 2022

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.

@sepsol
Copy link

sepsol commented Apr 20, 2022

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.

@punkuotukas
Copy link

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. 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants