techouse / sqlite3-to-mysql

Transfer data from SQLite to MySQL

Home Page:https://techouse.github.io/sqlite3-to-mysql/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No Default should be set in case of Auto-increment

DoctorAti opened this issue · comments

please update _create_table function line to this:

sql += " `{name}` {type} {notnull} {default} {auto_increment}, ".format(
                name=mysql_safe_name,
                type=column_type,
                notnull="NOT NULL" if column["notnull"] or column["pk"] else "NULL",
                auto_increment="AUTO_INCREMENT"
                if column["pk"] > 0 and column_type.startswith(("INT", "BIGINT")) and not compound_primary_key
                else "",
                default="DEFAULT " + column["dflt_value"]
                if column["dflt_value"] and column_type not in MYSQL_COLUMN_TYPES_WITHOUT_DEFAULT and not (column["pk"] > 0 and column_type.startswith(("INT", "BIGINT")) and not compound_primary_key)
                else "",
            )

previously for auto_increment fields also it was setting default values

in mysql setting default values of Auto Increment fields are not allowed.

Good spot. Fixed!