CREATE TABLE wrong format
Why is this statement ...
...formatted like this?

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.
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;
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'))
Is there no solution to this problem? Does anyone know of any other free online parsers (or at Windows command-line) that expose APIs?
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.
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
Hi guys, anyone have the same problem?
@umbertoB67 Yeah, I do
I also met this problem.
Is there no solution to this problem?
Hi guys, anyone have the same problem? I also met this problem. ) :