class Tabelas {
init(conexao) {
this.conexao = conexao
this.criarAtendimentos()
}
criarAtendimentos() {
const sql =
'CREATE TABLE IF NOT EXISTS Atendimentos (id in 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')
}
})
}
}
module.exports = new Tabelas
ERRO
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
conectado com sucesso
consign v0.1.6 Initialized in C:\alura\node-js
+ .\controllers\atendimentos.js
servidor rodando na porta 3000
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'in NOT NULL AUTO_INCREMENT, cliente varchar(50) NOT NULL, pet varchar(20), servi' at line 1
at Query.Sequence._packetToError (C:\alura\node-js\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Query.ErrorPacket (C:\alura\node-js\node_modules\mysql\lib\protocol\sequences\Query.js:79:18)
at Protocol._parsePacket (C:\alura\node-js\node_modules\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (C:\alura\node-js\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (C:\alura\node-js\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (C:\alura\node-js\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (C:\alura\node-js\node_modules\mysql\lib\Connection.js:88:28)
at Socket.<anonymous> (C:\alura\node-js\node_modules\mysql\lib\Connection.js:526:10)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
--------------------
at Protocol._enqueue (C:\alura\node-js\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Connection.query (C:\alura\node-js\node_modules\mysql\lib\Connection.js:198:25)
at Tabelas.criarAtendimentos (C:\alura\node-js\infraestrutura\tabelas.js:13:18)
at Tabelas.init (C:\alura\node-js\infraestrutura\tabelas.js:5:10)
at Handshake.<anonymous> (C:\alura\node-js\index.js:11:13)
at Handshake.<anonymous> (C:\alura\node-js\node_modules\mysql\lib\Connection.js:526:10)
at Handshake._callback (C:\alura\node-js\node_modules\mysql\lib\Connection.js:488:16)
at Handshake.Sequence.end (C:\alura\node-js\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:24)
at Handshake.Sequence.OkPacket (C:\alura\node-js\node_modules\mysql\lib\protocol\sequences\Sequence.js:92:8)
at Protocol._parsePacket (C:\alura\node-js\node_modules\mysql\lib\protocol\Protocol.js:291:23) {
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'in NOT NULL AUTO_INCREMENT, cliente varchar(50) NOT NULL, pet varchar(20), servi' at line 1",
sqlState: '42000',
index: 0,
sql: 'CREATE TABLE IF NOT EXISTS Atendimentos (id in 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))'
}
passei a tarde procurando e não consegui uma solução ainda, caso alguem souber agradeço, valeu