Git Product home page Git Product logo

Comments (4)

littleK0i avatar littleK0i commented on August 16, 2024

Interesting. Could you please add debug=True connection option and attach logs?

I suspect, this is how Exasol WebSocket protocol returns float values, regardless of NLS_NUMERIC_CHARACTERS setting.

from pyexasol.

huelf avatar huelf commented on August 16, 2024

Here's the Log:

2022-11-30 07:50:33.811 Connection attempt [10.10.30.196:8563]
2022-11-30 07:50:33.842 [WebSocket request #1]
{
  "command": "login",
  "protocolVersion": 3
}
2022-11-30 07:50:33.842 [WebSocket response #1]
{
  "status": "ok",
  "responseData": {
    "publicKeyPem": "<public key>",
    "publicKeyExponent": "010001",
    "publicKeyModulus": "<modulus>"
  }
}
2022-11-30 07:50:33.983 [WebSocket request #2]
{
  "username": "<username>",
  "password": "<password>",
  "driverName": "PyEXASOL 0.24.0",
  "clientName": "PyEXASOL",
  "clientVersion": "0.24.0",
  "clientOs": "Windows-10-10.0.17763-SP0",
  "clientOsUsername": "<username>",
  "clientRuntime": "Python 3.9.7",
  "useCompression": false,
  "attributes": {
    "currentSchema": "",
    "autocommit": true,
    "queryTimeout": 0
  }
}
2022-11-30 07:50:33.998 [WebSocket response #2]
{
  "status": "ok",
  "responseData": {
    "protocolVersion": 3,
    "timeZone": "EUROPE/BERLIN",
    "timeZoneBehavior": "INVALID SHIFT AMBIGUOUS ST",
    "sessionId": 1750902846820319232,
    "maxDataMessageSize": 67108864,
    "releaseVersion": "7.1.6",
    "databaseName": "exa_db1_dev",
    "productName": "EXASolution",
    "maxIdentifierLength": 128,
    "maxVarcharLength": 2000000,
    "identifierQuoteString": "\""
  }
}
2022-11-30 07:50:33.998 [WebSocket request #3]
{
  "command": "getAttributes"
}
2022-11-30 07:50:34.029 [WebSocket response #3]
{
  "status": "ok",
  "attributes": {
    "datetimeFormat": "YYYY-MM-DD HH24:MI:SS.FF6",
    "dateFormat": "YYYY-MM-DD",
    "numericCharacters": ".,",
    "dateLanguage": "ENG",
    "queryTimeout": 0,
    "timezone": "EUROPE/BERLIN",
    "timezoneBehavior": "INVALID SHIFT AMBIGUOUS ST",
    "snapshotTransactionsEnabled": true,
    "defaultLikeEscapeCharacter": "\\",
    "autocommit": true,
    "compressionEnabled": false,
    "currentSchema": "",
    "openTransaction": 0
  }
}
2022-11-30 07:50:35.811 [WebSocket request #4]
{
  "command": "execute",
  "sqlText": "EXPORT (\nselect cast(0.5 as DECIMAL(2,2)) as DECIMALCOLUMN\n, cast(0.6 as DOUBLE) as DOUBLECOLUMN\nfrom DUAL\n) INTO CSV\nAT 'https://192.168.100.75:43360' FILE '000.csv'\nWITH COLUMN NAMES"
}
2022-11-30 07:50:36.998 [WebSocket response #4]
{
  "status": "ok",
  "responseData": {
    "results": [
      {
        "resultType": "rowCount",
        "rowCount": 1
      }
    ],
    "numResults": 1
  }
}
2022-11-30 07:50:37.967 [WebSocket request #5]
{
  "command": "execute",
  "sqlText": "select cast(0.5 as DECIMAL(2,2)) as DECIMALCOLUMN\n, cast(0.6 as DOUBLE) as DOUBLECOLUMN\nfrom DUAL"
}
2022-11-30 07:50:37.983 [WebSocket response #5]
{
  "status": "ok",
  "responseData": {
    "results": [
      {
        "resultType": "resultSet",
        "resultSet": {
          "numColumns": 2,
          "numRows": 1,
          "numRowsInMessage": 1,
          "columns": [
            {
              "name": "DECIMALCOLUMN",
              "dataType": {
                "type": "DECIMAL",
                "precision": 2,
                "scale": 2
              }
            },
            {
              "name": "DOUBLECOLUMN",
              "dataType": {
                "type": "DOUBLE"
              }
            }
          ],
          "data": [
            [
              "0.5"
            ],
            [
              0.6
            ]
          ]
        }
      }
    ],
    "numResults": 1
  }
}
2022-11-30 07:50:37.983 [WebSocket request #6]
{
  "command": "execute",
  "sqlText": "ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ',.'"
}
2022-11-30 07:50:37.998 [WebSocket response #6]
{
  "status": "ok",
  "attributes": {
    "numericCharacters": ",."
  },
  "responseData": {
    "results": [
      {
        "resultType": "rowCount",
        "rowCount": 0
      }
    ],
    "numResults": 1
  }
}
2022-11-30 07:50:38.498 [WebSocket request #7]
{
  "command": "execute",
  "sqlText": "EXPORT (\nselect cast(0.5 as DECIMAL(2,2)) as DECIMALCOLUMN\n, cast(0.6 as DOUBLE) as DOUBLECOLUMN\nfrom DUAL\n) INTO CSV\nAT 'https://192.168.100.75:45003' FILE '000.csv'\nWITH COLUMN NAMES"
}
2022-11-30 07:50:39.654 [WebSocket response #7]
{
  "status": "ok",
  "responseData": {
    "results": [
      {
        "resultType": "rowCount",
        "rowCount": 1
      }
    ],
    "numResults": 1
  }
}
2022-11-30 07:50:39.654 [WebSocket request #8]
{
  "command": "execute",
  "sqlText": "select cast(0.5 as DECIMAL(2,2)) as DECIMALCOLUMN\n, cast(0.6 as DOUBLE) as DOUBLECOLUMN\nfrom DUAL"
}
2022-11-30 07:50:39.670 [WebSocket response #8]
{
  "status": "ok",
  "responseData": {
    "results": [
      {
        "resultType": "resultSet",
        "resultSet": {
          "numColumns": 2,
          "numRows": 1,
          "numRowsInMessage": 1,
          "columns": [
            {
              "name": "DECIMALCOLUMN",
              "dataType": {
                "type": "DECIMAL",
                "precision": 2,
                "scale": 2
              }
            },
            {
              "name": "DOUBLECOLUMN",
              "dataType": {
                "type": "DOUBLE"
              }
            }
          ],
          "data": [
            [
              "0,5"
            ],
            [
              0.6
            ]
          ]
        }
      }
    ],
    "numResults": 1
  }
}
2022-11-30 07:50:39.717 [WebSocket request #9]
{
  "command": "disconnect"
}

from pyexasol.

littleK0i avatar littleK0i commented on August 16, 2024

Ok, values are actually returned as floats from Exasol Websocket API.

The only reason why it works for pandas is that EXPORT command internally formats all values as strings, so NLS_NUMERIC_CHARACTERS is applied. It does not happen with normal fetching.

You may define custom fetch_mapper function to transform values manually.

Example of mapper function: https://github.com/exasol/pyexasol/blob/master/pyexasol/mapper.py#L62-L97

Example which sets mapper function as connection option: https://github.com/exasol/pyexasol/blob/master/examples/a04_fetch_mapper.py#L24

from pyexasol.

redcatbear avatar redcatbear commented on August 16, 2024

I am closing this ticket, since there was no response from the person asking in over a month since the last answer.

from pyexasol.

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.