Skip to content

Instantly share code, notes, and snippets.

@rafaelsanchezsouza
Created March 25, 2020 14:31
Show Gist options
  • Select an option

  • Save rafaelsanchezsouza/b7d82335e6a04857bffeaabf32baab00 to your computer and use it in GitHub Desktop.

Select an option

Save rafaelsanchezsouza/b7d82335e6a04857bffeaabf32baab00 to your computer and use it in GitHub Desktop.
erro: SQLITE_CANTOPEN
const knex = require("knex");
const configuration = require("../../knexfile");
const connection = knex(configuration.development);
module.exports = connection;
const express = require("express");
const routes = require( "./routes");
//inicializa aplicação
const app = express();
app.use(express.json());
app.use(routes);
//ouvir porta 3333
app.listen(3333);
// Update with your config settings.
module.exports = {
development: {
client: 'sqlite3',
connection: {
filename: "./src/database/db.sqlite"
},
migrations: {
directory: "./src/database/migrations"
},
useNullAsDefault: true,
},
staging: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
},
production: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}
};
const express = require("express");
const crypto = require("crypto");
const connection = require("./database/connection");
const routes = express.Router();
routes.post("/ongs", async (request,response) => {
const { name, email, whatsapp, city, uf } = request.body;
const id = crypto.randomBytes(4).toString("HEX");
await connection("ongs").insert({
id,
name,
email,
whatsapp,
city,
uf,
})
console.log(data);
return response.json({ id });
});
module.exports = routes;
@rafaelsanchezsouza
Copy link
Author

(node:6483) UnhandledPromiseRejectionWarning: Error: SQLITE_CANTOPEN: unable to open database file
(node:6483) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
(node:6483) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

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