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

loss of precision with non default locale

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.0.5
    • 1.0.7
    • Generic
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.