-
Notifications
You must be signed in to change notification settings - Fork 18
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
Connection string fails with special characters in password. #20
Comments
BTW, I would love to know the required PostgreSQL permissions for this utility to work. I can offer donate my skills with documentation and with some guidance maybe even generating some nice warnings for users who lack those permissions. |
@aviv-skillset can you share the full command that you ran? It may just be a matter of updating from:
to
(adding quotes) |
I believe the problem is deeper than I expected. I've tried to import this function instead of using the CLI binaries. import { typescriptOfSchema } from 'pg-to-ts';
typescriptOfSchema(`postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}`) I have investigated a bit an have seen you are using pg-promise which relies on brianc/node-postgres/pg-connection-string. This package probably is in charge of handling my problem. I personally connect pg like this import { DatabaseError, Pool, PoolConfig, QueryConfig } from 'pg';
const poolConfig: PoolConfig = {
user: DATABASE_USER,
host: DATABASE_HOST,
database: DATABASE_NAME,
password: DATABASE_PASSWORD,
port: DATABASE_PORT,
};
const pool = new Pool(poolConfig); and the same "problematic" password worked properly |
@aviv-skillset looking at the pg-connection-string page that you referenced, you may need to URL encode your password (and possibly the other fields) to make this work. So using your example:
If this works, I'd very much appreciate a PR to add a note about it to the README. I also think it would be desirable to support passing in connection parameters using environment variables as an alternative to a connection string. (I'd also happily accept a PR for that!) |
This database server is being used with node-postgres perfectly with same credentials.
on remote server
postgresql://myuser:Ex@mp!#[email protected]/mydbname
failson local docker container
postgresql://myuser:administrator@localhost:5431/mydbname
works fineAs you can see, the same user and database name is used, yet, when on the local machine when using "administrator" as a password without any special characters, then db connects just fine.
Is there any way to escape special characters?
The text was updated successfully, but these errors were encountered: