Created
March 25, 2020 14:31
-
-
Save rafaelsanchezsouza/b7d82335e6a04857bffeaabf32baab00 to your computer and use it in GitHub Desktop.
erro: SQLITE_CANTOPEN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const knex = require("knex"); | |
| const configuration = require("../../knexfile"); | |
| const connection = knex(configuration.development); | |
| module.exports = connection; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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' | |
| } | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(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.