-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
a command to start a db console/REPL
- Loading branch information
There are no files selected for viewing
4 comments
on commit cff0027
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Linuus Thank you for this proposal, I think this is the right direction. Alongside with tests, this should be expanded with the following CLI options:
% psql --help
# ...
Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "local socket") # MISSING SOCKET SUPPORT
-p, --port=PORT database server port (default: "5432")
-U, --username=USERNAME database user name (default: "luca")
-w, --no-password never prompt for password
-W, --password force password prompt (should happen automatically)
mysql --help
# ...
-D, --database=name Database to use.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
-P, --port=# Port number to use for connection or 0 for default to, in
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/services, built-in default (3306).
-S, --socket=name The socket file to use for connection.
-u, --user=name User for login if not current user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jodosha Yes I was thinking about that but if we specify all those options for the dbconsole
command it gets tied to the actual adapter, right? Different adapters can take different options. So I guess we must collect all options sent to the dbconsole
command and just pass it along to the connection_string
method and let it handle it?
EDIT: Hmm but that does not seem to be possible with Thor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Linuus Apart from Thor, I don't think it's a good idea and I'll tell you why in a second. 😄
First of all, it doesn't create a solid CLI, as it doesn't protect from databases changes. For instance, if a newer version of MySQL changes from --user
to --username
developers shouldn't notice it.
Secondly, it looses the point of this command at all. If they have to do bundle exec lotus dbconsole --port=1234 --username=luca --password=secret
, and figure out which args are part of Lotus, and which are part of the database CLI. I think they will go for the latter: psql ...
it will became easier to deal with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jodosha Yes, I agree :) I have tried to create a unified interface.
The only thing which is a bit weird is if I use mysql I can write
lotus dbconsole --password=foobar
and it will do it.
If I use the same command for psql it will discard the actual password and just bring up the password prompt.
lotus dbconsole --password=foobar
-> psql --password
But maybe that's not an issue. It may just be a bit hard to know what lotus options I can use for my DB.
If I do lotus dbconsole --help
and I see:
-S, --socket=name The socket file to use for connection.
I don't know if it applies to mysql, psql or anything else.
looks good, wondering if we should also support
mysql2
adapter too?