GithubHelp home page GithubHelp logo

Comments (7)

ddcw avatar ddcw commented on July 26, 2024 1

我今天发现tinyint类型数据解析的数据有问题,tinyint类型数据 0,解析后是 字符串128

  1. tinyint的数据我没验证过, 如果不符合要求,请自己修改相关代码, 也可以等下一个版本更新(时间不确定, 最近有点忙), 目前验证过的数据类型为varchar,char, date, int, time,timestamp,datetime

  2. DDL的属性目前只解析了是否为空(is_nullable),是否有默认值(default_value_utf8),注释(comment), 但是注释未加关键词comment和引号.... (未解析符号等其它属性)
    就像下面这样

(venv) 18:57:56 [root@ddcw21 innodb_parse]#python main.py --ddl /data/mysql_3314/mysqldata/db1/t20230821_2.ibd 

 CREATE Table  db1.t20230821_2(
id int NOT NULL  ,
id2 tinyint NULL  test tiny int,
id3 year NULL  ,
PRIMARY KEY(id)) ENGINE=InnoDB test ibd2sql;

from ibd2sql.

ddcw avatar ddcw commented on July 26, 2024

bigint类型数据做ddl里是正常能解析出来的,但是在数据里bigint类型数据都是None,而且主键字段好像也没有生成ddl标识,可以优化吗

  1. 对于bigint的支持, 目前未解析bigint的数据(忘了, tinyint倒是解析了...), 对于未解析的数据, 都是返回None,
    bigint和其它数据类型(不含LOB和JSON)将在下一个版本支持.
    若现在需要的话, 可以编辑 innodb_type.py 文件, 在第77行处添加如下代码即可
    	if dtype == 'bigint':
		_t = struct.unpack('>Q',bdata[:8])[0]
		return (_t&((1<<63)-1)) if _t&(1<<63) else -(_t&((1<<63)-1))
  1. 目前是支持主键(在最后一行)的, 如下为使用例子:
(venv) 09:46:47 [root@ddcw21 innodb_parse]#python main.py --ddl --sql /data/mysql_3314/mysqldata/db1/t20230820.ibd 

 CREATE Table  db1.t20230820(
id int NOT NULL  ,
aa bigint NULL  ,
PRIMARY KEY(id)) ENGINE=InnoDB ; 

insert into db1.t20230820 values("1","1");
insert into db1.t20230820 values("111111111","11111111111111");
(venv) 09:47:36 [root@ddcw21 innodb_parse]#

from ibd2sql.

HotKin avatar HotKin commented on July 26, 2024

感谢🙏

from ibd2sql.

HotKin avatar HotKin commented on July 26, 2024

请问下能字段备注和表备注,默认值这些能处理吗?现在的 sql不是很标准,有这些属性的话

from ibd2sql.

HotKin avatar HotKin commented on July 26, 2024

我今天发现tinyint类型数据解析的数据有问题,tinyint类型数据 0,解析后是 字符串128

from ibd2sql.

HotKin avatar HotKin commented on July 26, 2024

好的,了解😀

from ibd2sql.

ddcw avatar ddcw commented on July 26, 2024

我今天发现tinyint类型数据解析的数据有问题,tinyint类型数据 0,解析后是 字符串128

我刚试了下, tinyint的数据 未做符号判断,(其它的也没做符号判断, 但都是当作有符号来解析的,), 下一个版本再做符号判断吧...
临时解决办法, 编辑innodb_type.py文件的第77行处添加如下代码即可(和bigint一样处理方法...)

        if dtype == 'tinyint':
                tdata = struct.unpack('>B',bdata)[0]
                return -(128-tdata) if tdata < 128 else tdata -128

效果:

(venv) 17:32:18 [root@ddcw21 innodb_parse]#python main.py --sql /data/mysql_3314/mysqldata/db1/t20230825.ibd
insert into db1.t20230825 values("1","-2");
insert into db1.t20230825 values("2","-1");
insert into db1.t20230825 values("3","0");
insert into db1.t20230825 values("4","1");
insert into db1.t20230825 values("5","2");
(venv) 17:32:19 [root@ddcw21 innodb_parse]#

from ibd2sql.

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.