Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-143

loss of precision with non default locale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.5
    • Fix Version/s: 1.0.7
    • Component/s: Generic
    • Labels:
      None

      Description

      Found a strange behavior with float values.

      import mariadb
      import locale
       
      conn = {'host': '192.168.1.2', 'user': 'test', 'password': 'test'}
       
      db = mariadb.connect(**conn)
      qr = db.cursor()
       
      latitude = -24.971077771106
      longitude = -53.95170397719726
       
      qr.execute('set @lat=?, @lng=?', (latitude, longitude))
       
      qr.execute('select @lat, @lng')
      lat, lng = qr.fetchone()
      print(lat, lng)
      # Here, returns what's expected: -24.971077771106 -53.95170397719726
       
      locale.setlocale(locale.LC_ALL, 'pt_BR.utf8')
       
      qr.execute('select @lat, @lng')
      lat2, lng2 = qr.fetchone()
      print(lat2, lng2)
      # But here, returns: -24.0 -53.0
      

        Attachments

          Activity

            People

            Assignee:
            georg Georg Richter
            Reporter:
            lucianobarcaro Luciano Barcaro
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration