V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
yellowtail
V2EX  ›  MySQL

请问存入数据库的数据有两位精度,但是在数据库查看时发现数据只有一位精度是怎么回事,表是按 float 的默认设置的

  •  
  •   yellowtail · Jun 25, 2021 · 1682 views
    This topic created in 1779 days ago, the information mentioned may be changed or developed.
    sql1 = "CREATE TABLE IF NOT EXISTS `1min` ( `datetime` date,`open` float,`high` float,`low` float,`close` float)"
    cursor.execute(sql1)
    sql = 'insert into 1min(datetime,open,high,low,close) values(%(datetime)s,%(open)s,%(high)s,%(low)s,%(close)s);'
    

    { "ch": "market.btcusdt.kline.1min", "status": "ok", "ts": 1624553002810, "data": [ { "id": 1624552980, "open": 34280.05, "close": 34277.8, "low": 34259.01, "high": 34299.98, "amount": 17.59438, "vol": 603071.96902987, "count": 385 } ] } 获取的内容 +---------------------+---------+---------+---------+---------+ | datetime | open | high | low | close | +---------------------+---------+---------+---------+---------+ | 2021-06-24 00:45:00 | 33527.5 | 33580.8 | 33521.4 | 33573.6 | | 2021-06-25 00:40:00 | 34277.7 | 34277.7 | 34277.7 | 34277.7 | | 2021-06-25 00:41:00 | 34336.9 | 34338.5 | 34308 | 34311.5 | | 2021-06-25 00:42:00 | 34297.6 | 34310.9 | 34289.1 | 34310.9 | | 2021-06-25 00:43:00 | 34280.1 | 34300 | 34259 | 34259.7 | | 2021-06-25 00:44:00 | 34237.1 | 34237.1 | 34237.1 | 34237.1 | | 2021-06-25 00:45:00 | 34240.4 | 34243.1 | 34240.4 | 34243.1 | | 2021-06-25 00:46:00 | 34339.7 | 34339.7 | 34315.4 | 34315.4 | mysql 显示内容

    rekulas
        1
    rekulas  
       Aug 9, 2021
    众所周知,高精度值计算存储全球统一看法字符串最稳,所以用 decimal
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3055 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 14:15 · PVG 22:15 · LAX 07:15 · JFK 10:15
    ♥ Do have faith in what you're doing.