Coder Social home page Coder Social logo

Comments (5)

caseyandgina avatar caseyandgina commented on August 29, 2024 1

Thank you for the information. Though surprising behavior, it is working now, so I’ll close this.

from sql_exporter.

caseyandgina avatar caseyandgina commented on August 29, 2024

Hmm, surprisingly, not urlencoding the socket path works, e.g. data_source_name: 'postgres://app_sql_exporter@/run/postgresql:5432/postgres'

from sql_exporter.

burningalchemist avatar burningalchemist commented on August 29, 2024

Hi @caseyandgina,

There's no need to encode the DSN as it needs to be parsed by dburl library.

We only might need to encode the password if it contains special characters.

from sql_exporter.

caseyandgina avatar caseyandgina commented on August 29, 2024

I was thinking it was due to the dburl library, but this is nonstandard behavior. Usually, the extra unescaped slashes in the hostname portion of the URI break things, so I’ve long been accustomed to having to escape these in postgres:// URIs.

For example:

$ psql "postgres://postgres@/run/postgresql/postgres"
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "run/postgresql/postgres" does not exist
$ psql "postgres://postgres@%2Frun%2Fpostgresql/postgres"
psql (16.3 (Ubuntu 16.3-1.pgdg24.04+1))
Type "help" for help.

postgres=# 

It also makes reading the URI's unclear. I'd rather be able to specify all the connection parameters separately in the YML rather than using a URI, but that doesn't seem to be a possibility presently. Or keyword/value syntax like this, which would require specifying the driver as a separate parameter:

$ psql "user=postgres host=/run/postgresql dbname=postgres"
psql (16.3 (Ubuntu 16.3-1.pgdg24.04+1))
Type "help" for help.

postgres=#

from sql_exporter.

burningalchemist avatar burningalchemist commented on August 29, 2024

As mentioned above, this project historically relies on DSN and lately 'dburl' (https://github.com/xo/dburl) parsing library to handle connection strings for different databases, protocols, transports and parameters. It provides a unified way to connect to all the supported databases with minimal effort, and seems sufficient for the project goals. Please have a look at the dependency by the posted link for more details on parsing the strings. 👍

What's also possible is you may use environment variables as placeholders in the DSN string and interpolate parts of it as needed.

For now there is no intention to change the connection configuration anytime soon.

from sql_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.