Skip to content

CREATE TABLE wrong format #688

Description

@umbertoB67

Why is this statement ...
image
...formatted like this?
image

Activity

  1. mrmasterplan commented on Nov 25, 2022

    @mrmasterplan
    Contributor

    Please past your input sql code here as text so that we don't have to type your statement from a screenshot in order to test it. Also, please include details about what python version and what library version you are runing.

  2. umbertoB67 commented on Nov 30, 2022

    @umbertoB67
    Author

    I'm sorry for delay in answer.
    This is my input SQL:

    CREATE TABLE `ambienti` (
        `id` INT(3) NOT NULL AUTO_INCREMENT,
        `sigla` VARCHAR(1) NOT NULL,
        `nome` VARCHAR(100) NOT NULL,
        `gruppo` CHAR(1) NOT NULL,
        `id_criticita` INT(11) DEFAULT NULL,
        `is_visible` INT(1) NOT NULL DEFAULT '1',
        `raggruppamento` VARCHAR(45) DEFAULT NULL,
        PRIMARY KEY (`id`)
    )  ENGINE=INNODB AUTO_INCREMENT=11 DEFAULT CHARSET=LATIN1;
    

    I'm using the formatter at this page: https://sqlformat.org/, but using API I got the same result:

    CREATE TABLE `ambienti` (`id` INT(3) NOT NULL AUTO_INCREMENT,
                                                  `sigla` VARCHAR(1) NOT NULL,
                                                                     `nome` VARCHAR(100) NOT NULL,
                                                                                         `gruppo` CHAR(1) NOT NULL,
                                                                                                          `id_criticita` INT(11) DEFAULT NULL,
                                                                                                                                         `is_visible` INT(1) NOT NULL DEFAULT '1',
                                                                                                                                                                              `raggruppamento` VARCHAR(45) DEFAULT NULL,
                                                                                                                                                                                                                   PRIMARY KEY (`id`)) ENGINE=INNODB AUTO_INCREMENT=11 DEFAULT
    CHARSET=LATIN1;
    
  3. mrvaita commented on Dec 6, 2022

    @mrvaita

    If it can be of any help I can reproduce the error using sqlparse 0.4.3 and python 3.9 using the following code:

    sql = """
    CREATE TABLE `ambienti` (
        `id` INT(3) NOT NULL AUTO_INCREMENT,
        `sigla` VARCHAR(1) NOT NULL,
        `nome` VARCHAR(100) NOT NULL,
        `gruppo` CHAR(1) NOT NULL,
        `id_criticita` INT(11) DEFAULT NULL,
        `is_visible` INT(1) NOT NULL DEFAULT '1',
        `raggruppamento` VARCHAR(45) DEFAULT NULL,
        PRIMARY KEY (`id`)
    )  ENGINE=INNODB AUTO_INCREMENT=11 DEFAULT CHARSET=LATIN1;
    """
    print(sqlparse.format(sql, reindent=True, keyword_case='upper'))
    
  4. umbertoB67 commented on Dec 15, 2022

    @umbertoB67
    Author

    Is there no solution to this problem?
    Does anyone know of any other free online parsers (or at Windows command-line) that expose APIs?

  5. mrmasterplan commented on Dec 15, 2022

    @mrmasterplan
    Contributor

    I am not a maintainer of this project. I am also looking for an open-source, python, sql parser and have not found anything better. My solution to is that I am trying to contribute to this project to make it better and more useful for a greater number of people, but ultimately we need to wait for the project owner to devote time to this.

  6. umbertoB67 commented on Dec 27, 2022

    @umbertoB67
    Author

    Waiting for a solution I'm using this command line tool which works very well (Poor Man's T-SQL Formatter) ==> http://architectshack.com/poormanstsqlformatter.ashx

  7. umbertoB67 commented on Mar 14, 2023

    @umbertoB67
    Author

    Hi guys, anyone have the same problem?

  8. Nickelza commented on Apr 19, 2023

    @Nickelza

    @umbertoB67 Yeah, I do

  9. zhaojiuxiao commented on May 11, 2023

    @zhaojiuxiao

    I also met this problem.

  10. umbertoB67 commented on Jul 17, 2023

    @umbertoB67
    Author

    Is there no solution to this problem?

  11. aixiuh commented on Dec 18, 2023

    @aixiuh

    Hi guys, anyone have the same problem?
    I also met this problem. ) :

  12. mark-me commented on Jul 3, 2025

    @mark-me

    Bump

  13. Kirow commented on Jan 2, 2026

    @Kirow

    Wanted to use formatter for cleaner SQL in the generated docs, but it getting worse...
    Not usable for now.

  14. Nugetzrul3 commented on Jan 8, 2026

    @Nugetzrul3

    Have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions