-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/load db #2
Conversation
@eSlider, this is a nice PR, why did you close it ? |
const me = this; | ||
Promise.all([initSqlJs(), axios.get('./test.db', {responseType: 'arraybuffer'})]).then(res => { | ||
const SQLite = res[0], dbStorage = res[1]; | ||
const db = new SQLite.Database(new Uint8Array(dbStorage.data)); | ||
// language=SQLite | ||
// const rows = db.exec("SELECT count(*) FROM db_articles"); | ||
// console.log(rows); | ||
me.setState({db: db}); | ||
|
||
}).catch(err => { | ||
me.setState({err}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const me = this; | |
Promise.all([initSqlJs(), axios.get('./test.db', {responseType: 'arraybuffer'})]).then(res => { | |
const SQLite = res[0], dbStorage = res[1]; | |
const db = new SQLite.Database(new Uint8Array(dbStorage.data)); | |
// language=SQLite | |
// const rows = db.exec("SELECT count(*) FROM db_articles"); | |
// console.log(rows); | |
me.setState({db: db}); | |
}).catch(err => { | |
me.setState({err}); | |
}); | |
Promise.all([ | |
initSqlJs(), | |
fetch('test.db', {responseType: 'arraybuffer'}) | |
]).then(([SQLite, dbStorage]) => { | |
this.setState({db: new SQLite.Database(new Uint8Array(dbStorage.data))}); | |
}).catch(err => { | |
this.setState({err}); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lovasoa, thank you for the advise to use fetch
. I will use it.
@@ -70,7 +81,7 @@ export default class App extends React.Component { | |||
<textarea | |||
onChange={e => this.exec(e.target.value)} | |||
placeholder="Enter some SQL. No inpiration ? Try “select sqlite_version()”" | |||
></textarea> | |||
>SELECT count(*) FROM db_articles</textarea> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>SELECT count(*) FROM db_articles</textarea> | |
SELECT * FROM db_articles |
@@ -1,8 +1,8 @@ | |||
import React from "react"; | |||
import axios from "axios"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import axios from "axios"; |
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json">--> | ||
<!-- <link rel="shortcut icon" href="%PUBLIC_URL%/fav/favicon.ico">--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | |
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | |
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json">--> | |
<!-- <link rel="shortcut icon" href="%PUBLIC_URL%/fav/favicon.ico">--> | |
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | |
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But where is the manifest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops 😁 You are right, there is no manifest, let's remove this line.
@@ -9,6 +9,7 @@ | |||
"main": "src/index.js", | |||
"license": "MIT", | |||
"dependencies": { | |||
"axios": "^0.19.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"axios": "^0.19.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eSlider, this is a nice PR, why did you close it ?
@lovasoa, it's breaks previous behavior.
Here are the changes:
- Download an sqlite database file (axios)
- Prepare downloaded file to handle it right (that was not easy :)
- Add favicon to prevent 404 errors
- Remove load of
manifest.json
- that not exists - Lock packages to get working version
- Add an select SQL query as a value for textearea
- Publish to another place: link
- Circle CI:
If you ok with, I will open PR again.
P.S. And thank you so much for you simple react-boilerplate! It's amazing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello !
Download an sqlite database file (axios)
You don't need to add a dependency just to make an HTTP request. Let's just use fetch
Prepare downloaded file to handle it right (that was not easy :)
?
Add favicon to prevent 404 errors
✔️
Lock packages to get working version
✔️
Add an select SQL query as a value for textearea
✔️
Publish to another place: link
Circle CI:
Automated static content build
Publish build in a gh-pages branch
Disable jekyll post processing
Prepare demo to work over github pages CDN
Get load generated assets using relative paths (That what I am working on)
Let's just keep the current netlify CD (https://sqljs-react-demo.netlify.com/). I don't think we need to switch to github pages.
I highlighted a few suggested changes |
No description provided.