Closed dfo-db closed 1 year ago
I just had a quick test and found the forward slash in the db password will cause url parsing issue. But the server should give correct error, in my case, I got:
{
"error": "cannot parse `postgres://test:xxxxxx@localhost:5432/test_db`: failed to parse as URL (parse "postgres: //test: pa/ss@localhost: 5432/test_db": invalid port ": pa" after host)"
}
When I set an incorrect password, I got this error:
{
"error": "failed to connect to `host=localhost user=test database=test_db`: failed SASL auth (FATAL: password authentication failed for user "test" (SQLSTATE 28P01))"
}
If you get db not found error
, that means your connection has been correctly established. Can you share with me the url that you used to call the api?
@dfo-db can you try to change the database definition from piq to test_db, and try again?
@elgs I'm using: http://localhost:8080/test_db/test_table
Also, when I change from piq to test_db I get (it's a long one, but here's the start of panic):
Also, if I put a completely gibberish connection string in, for username and password, I still get "database test_db not found"!
Yes, this is caused by connection not valid. Sorry for the panic, though I couldn't reproduce this issue. I just released a new version which added additional checks. Can you please try to get the latest version and try again?
If you installed it using go install, try:
GOPROXY=direct go install github.com/elgs/gosqlapi@all
Make sure the version is 36.
$ gosqlapi -v
36
This will not fix the error, but hopefully we will get better error messages. Thanks.
Regarding database test_db not found
, that means test_db
is not defined in your config file. Assuming you changed piq to test_db, you will need to restart the server, in case you haven't.
@elgs Thank you! Yes, I did restart. I'm using version 36 now and I'm getting this on return of GET in postman:
SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 32 of the JSON data
Which is just because the error is malformed, the raw data is this:
{"error":"sql: unknown driver "pqx" (forgotten import?)"}
I just changed the type to postgres:
"type": "postgres",
It now works! So it was my fault.
Thank you so much for being so responsive! Awesome project, well done.
Hey!
Just trying out your amazing looking project.
I assume the issue is because it can't actually create a connection, as when I change the URL user and pass, it's the same message.
settings:
Now, there is a forward slash in the database password. Could this be the issue? As it may be effecting the URL.
The test db is there!
Also, would be great to have a connection error, rather than a db not found error.
Thanks!