V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
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 · 2021-06-25 00:54:04 +08:00 · 868 次点击
    这是一个创建于 1033 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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  
       2021-08-09 22:40:45 +08:00
    众所周知,高精度值计算存储全球统一看法字符串最稳,所以用 decimal
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5422 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:57 · PVG 16:57 · LAX 01:57 · JFK 04:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.