Обсуждение: [GENERAL] Feature proposal, DBURL: psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

Поиск
Список
Период
Сортировка

[GENERAL] Feature proposal, DBURL: psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Hans Schou
Дата:
Hi

The dburl (or dburi) has become common to use by many systems connecting to a database. The feature is that one can pass all parameters in a string, which has similar pattern as http-URI do.
Especially when using psql in a script, having the credentials in one string is convenient.

The syntax could be:
  [scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,column...]*]]]|sql]]]

Example of usage:
  psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

Where
  Scheme: pgsql
  Username: joe
  Password: p4zzw0rd
  Host: example.org
  Port: 2345
  Database: dbname

I have attached an example of how it could be implemented. It uses libpcre RegEx to pass the dburl.

best regards
Hans
Вложения

Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Christoph Moench-Tegeder
Дата:
## Hans Schou (hans.schou@gmail.com):

> Example of usage:
>   psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

Make the scheme "postgresql" and you're here:
https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
"32.1.1.2. Connection URIs".

Regards,
Christoph

--
Spare Space


Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Albe Laurenz
Дата:
Hans Schou wrote:
> The dburl (or dburi) has become common to use by many systems connecting to a database.
> The feature is that one can pass all parameters in a string, which has similar pattern as
> http-URI do.
> 
> Especially when using psql in a script, having the credentials in one string is
> convenient.
> 
> 
> The syntax could be:
> 
> [scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,col
> umn...]*]]]|sql]]]
> 
> 
> Example of usage:
>   psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

[...]

> I have attached an example of how it could be implemented. It uses libpcre RegEx to pass
> the dburl.

Unless I misunderstand, this has been in PostgreSQL since 9.2:

https://www.postgresql.org/docs/current/static/libpq-connect.html#AEN45571
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=b035cb9db7aa7c0f28581b23feb10d3c559701f6

Yours,
Laurenz Albe

Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Adrian Klaver
Дата:
On 07/05/2017 06:15 AM, Albe Laurenz wrote:
> Hans Schou wrote:
>> The dburl (or dburi) has become common to use by many systems connecting to a database.
>> The feature is that one can pass all parameters in a string, which has similar pattern as
>> http-URI do.
>>
>> Especially when using psql in a script, having the credentials in one string is
>> convenient.
>>
>>
>> The syntax could be:
>>
>> [scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,col
>> umn...]*]]]|sql]]]
>>
>>
>> Example of usage:
>>    psql pgsql://joe:p4zzw0rd@example.org:2345/dbname
>
> [...]
>
>> I have attached an example of how it could be implemented. It uses libpcre RegEx to pass
>> the dburl.
>
> Unless I misunderstand, this has been in PostgreSQL since 9.2:

T think the OP was referring to the latter part of:

[scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,column...]*]]]|sql]]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The thing is that in a quick search on this I did not find a reference
implementation of this to compare against.


> Yours,
> Laurenz Albe
>


--
Adrian Klaver
adrian.klaver@aklaver.com


[GENERAL] Re: Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Thomas Kellerer
Дата:
Hans Schou schrieb am 05.07.2017 um 14:27:
> The dburl (or dburi) has become common to use by many systems
> connecting to a database. The feature is that one can pass all
> parameters in a string, which has similar pattern as http-URI do.
>
> Especially when using psql in a script, having the credentials in one string is convenient.
>
> The syntax could be:
>   [scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,column...]*]]]|sql]]]

Besides the fact that something like that is already possible:

What's the use of "table" and "column" in the URI? You connect to a database, not to a table.

Thomas

Re: [GENERAL] Feature proposal, DBURL: psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Hans Schou
Дата:
2017-07-05 15:15 GMT+02:00 Albe Laurenz <laurenz.albe@wien.gv.at>:

Unless I misunderstand, this has been in PostgreSQL since 9.2:

Sorry! I did not read the *new* manual.
(OK, 9.2 is not that new)

It is even mentioned in the man page.

Then I have a new proposal. Write a note about in
  psql --help

./hans
2017-07-05 16:29 GMT+02:00 Thomas Kellerer <spam_eater@gmx.net>:
Hans Schou schrieb am 05.07.2017 um 14:27:
> The dburl (or dburi) has become common to use by many systems
> connecting to a database. The feature is that one can pass all
> parameters in a string, which has similar pattern as http-URI do.
>
> Especially when using psql in a script, having the credentials in one string is convenient.
>
> The syntax could be:
>   [scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,column...]*]]]|sql]]]

Besides the fact that something like that is already possible:

What's the use of "table" and "column" in the URI? You connect to a database, not to a table.

With 'table' the idea was  to do a "SELECT * FROM table" on that.
With 'column' added only that or those columns would be listed.

The "sql" part in the end was supposed to be a SQL-statement to be executed, like:
  psql "postgresql://localhost/dbname/INSERT INTO foo VALUES($RANDOM)"
which should be equal to
  echo "INSERT INTO foo VALUES($RANDOM)" | psql postgresql://localhost/dbname

./hans

Re: [GENERAL] Feature proposal, DBURL: psql pgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Hans Schou
Дата:
2017-07-05 15:41 GMT+02:00 Adrian Klaver <adrian.klaver@aklaver.com>:

[scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,column...]*]]]|sql]]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The thing is that in a quick search on this I did not find a reference implementation of this to compare against.

"dsn" is only relevant when the scheme is ODBC.

In a situation where an application (like Drupal) get connect string (URI) it should be able to find the right driver to use. In case with of ODBC, a dsn (Data Source Name) is needed.

./hans

Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname

От
Adrian Klaver
Дата:
On 07/05/2017 08:31 AM, Hans Schou wrote:
> 2017-07-05 15:41 GMT+02:00 Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>>:
>
>
>     [scheme[<+>dsn]]://[[username[:[password]]@][host][:port][/[dbname][/[[table[/[column[,column...]*]]]|sql]]]
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>     The thing is that in a quick search on this I did not find a
>     reference implementation of this to compare against.
>
>
> "dsn" is only relevant when the scheme is ODBC.

That was formatting error on my part, I was trying to point to the back
half of the URI. The part with the table/column/sql sections.

>
> In a situation where an application (like Drupal) get connect string
> (URI) it should be able to find the right driver to use. In case with of
> ODBC, a dsn (Data Source Name) is needed.
>
> ./hans
>


--
Adrian Klaver
adrian.klaver@aklaver.com