Code Monkey home page Code Monkey logo

Comments (8)

IlyaSukhanov avatar IlyaSukhanov commented on July 18, 2024

I'm presuming the host dbname port user extraction logic does not support all the formats of connection strings that psycopg supports.

from aws-xray-sdk-python.

IlyaSukhanov avatar IlyaSukhanov commented on July 18, 2024

psycopg2.connect() Supports 3 variants of operation:

  1. psycopg2.connect("dbname=test user=postgres password=secret")
  2. psycopg2.connect(dbname="test", user="postgres", password="secret")
  3. psycopg2.connect()

Variant 3 is ok if arguments are passed via env-vars:
Any other connection parameter supported by the client library/server can be passed either in the connection string or as a keyword. The PostgreSQL documentation contains the complete list of the supported parameters. Also note that the same parameters can be passed to the client library using environment variables.

aws-xray-sdk-python does not support variant 3 or mix of variant 2 and 3.

from aws-xray-sdk-python.

IlyaSukhanov avatar IlyaSukhanov commented on July 18, 2024

It may not be obvious but use of patch_all() or patch of psycopg will cause any code error out and stack trace when opening connection to database. This is quite serious bug.

from aws-xray-sdk-python.

IlyaSukhanov avatar IlyaSukhanov commented on July 18, 2024

After some more digging around turns out problem was different but solution remained the same.

Psycopg supports passing of database name both as dbname and as database. SQL Alchemy uses the database variety triggering the bug.
https://github.com/psycopg/psycopg2/blob/master/lib/__init__.py#L96

There may still be a way to use method 3 as described in comment above but its not obvious. And psycopg will error out if there are no arguments on connect. https://github.com/psycopg/psycopg2/blob/master/lib/__init__.py#L122 Maybe if you set port via kwarg / dsn but the rest via env var?

from aws-xray-sdk-python.

revmischa avatar revmischa commented on July 18, 2024

Getting this error when database is localhost

from aws-xray-sdk-python.

Tankanow avatar Tankanow commented on July 18, 2024

Is this still an issue or was this solved with 180de75?

from aws-xray-sdk-python.

haotianw465 avatar haotianw465 commented on July 18, 2024

@Tankanow this is fixed in the commit you mentioned. We will close this issue once the commit is released (which should be soon).

from aws-xray-sdk-python.

haotianw465 avatar haotianw465 commented on July 18, 2024

The fix is released in 2.2.0 https://pypi.org/project/aws-xray-sdk/. Closing.

from aws-xray-sdk-python.

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.