2
respostas

MYSQL

Bom dia ao inserir o codigo abaixo eu recebo um erro no console

criarAtendimentos() {
        const sql = "CREATE TABLE Atendimentos (CREATE TABLE Atendimentos (id int NOT NULL AUTO_INCREMENT, cliente varchar(50) NOT NULL, pet varchar(20),servico varchar(20) NOT NULL, status varchar(20) NOT NULL, observacoes text, PRIMARY KEY(id))"

        this.conexao.query(sql, (erro => {
            if(erro) {
                console.log(erro)
            }else {
                console.log('Tabela Atendimentos criada com sucesso')
            }
        }
        ))
    }

erro: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE TABLE Atendimentos (id int NOT NULL AUTO_INCREMENT, cliente varchar(50) N' at line 1 at Query.Sequence._packetToError (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14) at Query.ErrorPacket (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\protocol\sequences\Query.js:79:18) at Protocol._parsePacket (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\protocol\Protocol.js:291:23) at Parser._parsePacket (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\protocol\Parser.js:433:10) at Parser.write (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\protocol\Parser.js:43:10) at Protocol.write (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\protocol\Protocol.js:38:16) at Socket. (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\Connection.js:88:28) at Socket. (C:\Users\Rafael\Documents\cursos\NODE\alura-api\node_modules\mysql\lib\Connection.js:526:10

2 respostas

Consegui resolver :)

Rafael, poste sua solução, por favor.