Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Set defaults for host, port, dbname and user later in the invocation#8

Open
waterkip wants to merge 1 commit intogmr:masterfrom
waterkip:set-defaults
Open

Set defaults for host, port, dbname and user later in the invocation#8
waterkip wants to merge 1 commit intogmr:masterfrom
waterkip:set-defaults

Conversation

@waterkip
Copy link

The problem is that if one uses sqlalchemy or some other tool that uses some
kind of object that returns None for a value, eg the port you need to
reimplement a lot of the code that is in this module already.

from sqlalchemy.engine.url import make_url

uri = make_url('postgres://localhost/foo');
# yields an error that a NoneType cannot be used for int();
password = getpass(uri.host, uri.port, uri.username, uri.database);

In order to fix this a lot of the defaults need to be implemented at the caller
level.

Furthermore, the default database name is the name of the user that is supplied
to the function, eg, a user 'foo' will default to the database 'foo', as seen
in behaviour by psql -U foo where 'foo' isn't your username of the OS.

Signed-off-by: Wesley Schwengle wesley@opperschaap.net

The problem is that if one uses sqlalchemy or some other tool that uses some
kind of object that returns None for a value, eg the port you need to
reimplement a lot of the code that is in this module already.

    from sqlalchemy.engine.url import make_url

    uri = make_url('postgres://localhost/foo');
    # yields an error that a NoneType cannot be used for int();
    password = getpass(uri.host, uri.port, uri.username, uri.database);

In order to fix this a lot of the defaults need to be implemented at the caller
level.

Furthermore, the default database name is the name of the user that is supplied
to the function, eg, a user 'foo' will default to the database 'foo', as seen
in behaviour by `psql -U foo` where 'foo' isn't your username of the OS.

Signed-off-by: Wesley Schwengle <wesley@opperschaap.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant