FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Feature/load db by eSlider · Pull Request #2 · sql-js/react-sqljs-demo · GitHub

/ react-sqljs-demo Public template

Feature/load db - #2

Closed
eSlider wants to merge 3 commits into
sql-js:masterfrom
produktor:feature/load-db
Closed

Feature/load db#2
eSlider wants to merge 3 commits into
sql-js:masterfrom
produktor:feature/load-db

Conversation

eSlider commented Jun 12, 2020

Copy link
Copy Markdown

No description provided.

eSlider closed this Jun 12, 2020

lovasoa commented Jun 12, 2020

Copy link
Copy Markdown
Member

@eSlider, this is a nice PR, why did you close it ?

Comment thread src/App.js
Comment on lines +18 to +29
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});
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
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});
});

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@lovasoa, thank you for the advise to use fetch. I will use it.

Comment thread src/App.js
onChange={e => this.exec(e.target.value)}
placeholder="Enter some SQL. No inpiration ? Try “select sqlite_version()”"
></textarea>
>SELECT count(*) FROM db_articles</textarea>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
>SELECT count(*) FROM db_articles</textarea>
SELECT * FROM db_articles

Comment thread src/App.js
@@ -1,8 +1,8 @@
import React from "react";
import axios from "axios";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
import axios from "axios";

Comment thread public/index.html
Comment on lines -12 to +13
<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">-->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
<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">

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

But where is the manifest?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ooops 😁 You are right, there is no manifest, let's remove this line.

Comment thread package.json
"main": "src/index.js",
"license": "MIT",
"dependencies": {
"axios": "^0.19.2",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
"axios": "^0.19.2",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@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:
    • 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)

If you ok with, I will open PR again.

P.S. And thank you so much for you simple react-boilerplate! It's amazing!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

lovasoa commented Jun 12, 2020

Copy link
Copy Markdown
Member

I highlighted a few suggested changes

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL