Use a google sheet as your web app database (Slingcode)

Поділитися
Вставка
  • Опубліковано 14 жов 2024
  • Learn how to use Google Sheets as a simple database for your single-page progressive web app. This technique is easy to set up and doesn't require complicated authentication, libraries, or APIs. Go to bettersheets.co to get more out of Google Sheets.
    PS You can follow along using the editor at slingcode.net

КОМЕНТАРІ • 92

  • @BetterSheets
    @BetterSheets 2 роки тому +7

    Thanks for the shoutout Chris! Great way to make a quick website with dynamic data that you can fill in with a google sheet.

    • @mccormix
      @mccormix  2 роки тому +2

      No problem, glad you liked the video!

  • @docubusiness8101
    @docubusiness8101 2 роки тому +2

    Your method is so much more efficient for read-only!

  • @Senjalkumar
    @Senjalkumar Рік тому

    Thank you, Chris! from the bottom of my heart for creating such an exceptional learning video. Your expertise and dedication have made a significant difference in my understanding and overall learning experience. I eagerly look forward to exploring more of your content and continuing my educational journey with your guidance. Thanks again.

    • @mccormix
      @mccormix  Рік тому

      Thank you I'm glad it was helpful for you.

  • @academyonnet
    @academyonnet Рік тому

    Thank you very much for making something so simple and yet useful.

    • @mccormix
      @mccormix  Рік тому +1

      Thank you, I'm glad it's useful for you.

  • @BakaNekoCh
    @BakaNekoCh 2 місяці тому

    It worked. Beautiful! Now gotta figure out how to post.

    • @mccormix
      @mccormix  Місяць тому

      You should be able to upload the contents of the zip file to any web hosting provider.

  • @rohanphadnis6812
    @rohanphadnis6812 Рік тому +2

    THIS IS A LIFESAVER! LOVE IT!

  • @keletsolwate2353
    @keletsolwate2353 2 роки тому +1

    This is great. I am looking to create knowledge base. Can I add a search feature on the front end linking to the google sheets database?

    • @cotychaveS
      @cotychaveS 2 роки тому

      can you share the code to search please, thank you very much

  • @felleg4737
    @felleg4737 3 роки тому +2

    it’s a funny way of doing this.
    looks like a cool hack to avoid the process of requesting credentials, setting up auth, writing some backend code to serve it all, etc. yes, you can’t modify the data this way, but you may not need to.

  • @jbean92
    @jbean92 2 роки тому +2

    Great video, thank you! Is it possible to switch between different tabs in the google sheet using this method?

    • @mccormix
      @mccormix  2 роки тому +1

      Yes it is possible to download a different sheet. Here's how:
      1. When you switch sheets in Google Sheets, you will see the URL change with a parameter like `#gid=12345` on the end.
      2. Copy the `gid=...` part.
      3. Paste it onto the end of your fetch URL in the web app with an & like this: `&gid=...`.
      After that when you make your request it will be for the sheet you targeted.

    • @jbean92
      @jbean92 2 роки тому

      @@mccormix worked perfectly! Thank you very much!

  • @openclass4all
    @openclass4all 3 роки тому +4

    Thank you for this video, very informative

    • @mccormix
      @mccormix  3 роки тому +1

      Thank you, I'm glad it was useful!

  • @diababdelkrim9454
    @diababdelkrim9454 2 роки тому +1

    Thank you very much, it's a great video

  • @aluracing8908
    @aluracing8908 2 роки тому +1

    Hi this is great! You solve me a problem that tooka me more than 3 hours te resolve!.
    Any idea how i can select/print a specific cell with this method? Thanks!

    • @mccormix
      @mccormix  2 роки тому +2

      Yes, you can select a specific cell. Once the CSV is parsed you get an array of objects. Each object is one row in the sheet. So if you wanted to get the 3rd row you would do `csv[2]`. Then to look up the cell in that row you simply find it by name. For example: `csv[2]["price"]` will get the 3rd row and the column named "price". Best of luck.

  • @arylima6116
    @arylima6116 3 роки тому +3

    Thank you sir. Can you add search box, so when I write "sword" in search box its only display Sword description and price? Hope for next tutorial🙏

    • @mccormix
      @mccormix  3 роки тому +2

      You an do this with an "onchange" event listener. When the change comes in you filter the list.

    • @arylima6116
      @arylima6116 3 роки тому +3

      @@mccormix Thank you sir

    • @cotychaveS
      @cotychaveS 2 роки тому

      @@arylima6116 can you share the code to search please, thank you very much

  • @KuldeepSingh-pl7rv
    @KuldeepSingh-pl7rv 2 роки тому +1

    if you want to perform CRUD action with this google sheet database then you would need to write some function at google sheet apps script side too. and in that case this won't gonna help. although nice tutorial

  • @TRC00020
    @TRC00020 Рік тому +1

    Can you read and write via the Web App to Google sheets?

    • @mccormix
      @mccormix  Рік тому +1

      No unfortunately you can not. I don't think even reading is working any more since they changed something on the server side.

  • @steph291
    @steph291 2 роки тому

    thanks ! it is useful ... at my job they based the company computer logistic on googlesheet. they are getting bigger and they need a proper ERP.
    BTW question : what if we have multiples sheets in a csv ?

  • @sameerk12982
    @sameerk12982 2 роки тому

    Hello from India.. superb tutorial...easy to understand..very helpful... is it possible to write data back to sheet as well? If so kindly show us the way. Highly appreciated.

    • @mccormix
      @mccormix  2 роки тому +1

      Is it not possible with this technique. You can only read. To write you need an API key and use a different method.

    • @sameerk12982
      @sameerk12982 2 роки тому

      @@mccormix thx for replying...

  • @shehzadqadri1381
    @shehzadqadri1381 2 роки тому +1

    i'm facing this error, kindly give me solution if you have?
    from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

    • @mccormix
      @mccormix  Рік тому

      It seems like they changed the CORS settings on the server and this technique no longer works.

  • @jesuitsgvn
    @jesuitsgvn Рік тому

    Thanks for this great video and explanation. Can you suggest a way to do exactly this without using the "fetch" command? Unfortunately my hosting provider does not allow fetch.

    • @mccormix
      @mccormix  Рік тому

      You will need to find a hosting provider that allows fetch. Almost any hosting provider will allow this. For free you can use GitHub pages.

  • @Siddhartharaj-d9h
    @Siddhartharaj-d9h Рік тому

    how to fetch google sheet data to github hosted website? i am facing cross origin problem

  • @Coder-ki4hq
    @Coder-ki4hq 2 роки тому +1

    When I move the script code in script.js file and provide the src in script tag in html the code doesn't load table data, However when the same code is run in one single html page it works properly, any idea why it's not working or suggestions how to make it work

    • @mccormix
      @mccormix  2 роки тому

      Try to open the developer console and see if there are any errors printed. If there are no errors make sure your script.js file is being loaded by putting `alert("hi");` at the top and see if the message shows.

  • @rafi_45
    @rafi_45 Рік тому

    thank you so much sir. best.

  • @dentReviews
    @dentReviews 2 роки тому

    i followed your code to a T, but when i get to the first step where it dumps the cell data into the page (7:05), nothing happens on my page. no data. Sheet is public, sheet link is correct, quadruple checked all the code... no idea why, but mine isn't pulling date into the html...

    • @dentReviews
      @dentReviews 2 роки тому +1

      fyi, if i click the link it does download the csv file, so that appears to work... but the javascript doesn't appear to be working.

    • @iveelbold
      @iveelbold 2 роки тому

      same here..

    • @patrick_wade
      @patrick_wade 2 роки тому

      yeah same here, double checked code. On inspect i get the CORS policy error. Is this a new thing since this video tutorial.

    • @mccormix
      @mccormix  Рік тому

      It seems like they changed something on the server and this no longer works.

  • @alexusfort6476
    @alexusfort6476 3 роки тому +1

    Thanks, do you know is it possible to export Google sheets table directly to some mysql table?

    • @mccormix
      @mccormix  3 роки тому

      Yes it's possible. Here are some ways to connect a Google sheets table to a database: www.quora.com/Is-there-a-way-to-connect-Google-sheets-to-MySQL?share=1

  • @brianrompis7467
    @brianrompis7467 2 роки тому +1

    Thank you, sir.
    Do you know how to address the other sheet if there are multiple sheets in the document?

    • @brianrompis7467
      @brianrompis7467 2 роки тому +1

      Nevermind, found it.

    • @markverhulst8886
      @markverhulst8886 2 роки тому

      Where did you find the code for other sheets?

    • @markverhulst8886
      @markverhulst8886 2 роки тому

      @@brianrompis7467 do you have example of using the other sheets in google sheets?

    • @mccormix
      @mccormix  2 роки тому +1

      It is possible to download a different sheet. Here's how:
      1. When you switch sheets in Google Sheets, you will see the URL change with a parameter like `#gid=12345` on the end.
      2. Copy the `gid=...` part.
      3. Paste it onto the end of your fetch URL in the web app with an & like this: `&gid=...`.
      After that when you make your request it will be for the sheet you targeted.

    • @mccormix
      @mccormix  2 роки тому

      Yes, you must use the `gid=` parameter, copied from the original Google Sheet URL when you switch sheets. See my other comment for more details.

  • @Vietnamyearsofhistory
    @Vietnamyearsofhistory Рік тому

    Hi admin
    !
    THis code do not work with Browser Usage from 10'39
    I did exactily like you
    How to fix???
    Please

    • @mccormix
      @mccormix  Рік тому

      I guess they have changed something on the server side and this no longer works.

  • @cotychaveS
    @cotychaveS 2 роки тому

    Gracias por este gran aporte! Solo que estamos trabados en como colocar un filtro o un search Box de los datos que traemoa de gsheets, muchas gracias!!

  • @danielbastos3991
    @danielbastos3991 2 роки тому

    Great video! Thank you, Chris!
    I'm trying to add a css to create different "cards" for each row data (I'm also trying to add buttons). But when I tryied, the CSS was applyied just once to all the data in the page. I tryied to create a div, but when I do this, I only receive the data from the 1st row. Exist another workaround to create those tipes of "cards"?
    What I did:
    csv.forEach(function(row) {
    main.classList.add('card');
    div= main.innerHTML += row.Title + "" + row.Date + "" + row.Tag;

    • @mccormix
      @mccormix  2 роки тому

      You need to use something like this:
      div = document.createElement("div");
      div.classList.add("card");
      main.appendChild(div);

    • @cotychaveS
      @cotychaveS 2 роки тому +1

      puedes usar bootstrap ejemplo: main.innerHTML += `



      `+row.NCONTRATO+`
      `+row.TIPO+`
      `+row.SERV+`



      `;

  • @tazulislam2698
    @tazulislam2698 2 роки тому

    Sir, how can i write, edit, delete google sheet rows and cells using this tricks.

    • @mccormix
      @mccormix  Рік тому

      Using this technique it's read-only. If you want to write, edit, or delete you will need to use the Google Sheets API.

  • @RyRy_Createss
    @RyRy_Createss Рік тому

    This is so useful. Thank you so much.

  • @cotychaveS
    @cotychaveS 2 роки тому

    can you share the code to search please, thank you very much

  • @adriano_silva_
    @adriano_silva_ Рік тому

    Thank you!

  • @RiiiiNNN
    @RiiiiNNN 2 роки тому

    Thank you this great video sir. But, can you please do it with a dropdown choices? Thank you.

    • @mccormix
      @mccormix  2 роки тому

      I'm sorry, I don't know what you mean. A dropdown of choices for what?

    • @RiiiiNNN
      @RiiiiNNN 2 роки тому

      Dropdown lists of items for example

  • @KLead963
    @KLead963 3 роки тому

    Could you please help? I need to know how to transfer data from google sheet to g-suit admin directory by using submit button for example! or when I submit a google form, the google form inputs go automatically to g-suit admin directory! I hope that I explained what I want correctly, please advise, thanks.

    • @mccormix
      @mccormix  3 роки тому

      Hello! I'm sorry, I don't know how to do this. Best of luck finding a solution!

  • @Coder-ki4hq
    @Coder-ki4hq 2 роки тому

    Can you suggest how to automatically update data on web page as soon as there is some updation on excel sheet. As refreshing the page again and again is not a good option nor is setInterval or timeout function. Kindly reply ASAP, a bit urgent

    • @mccormix
      @mccormix  2 роки тому

      Apart from polling using setInterval, the way to accomplish this is to use the Google Drive push notifications interface. You can find more info about that here: developers.google.com/drive/v3/web/push

  • @MaiconGonzalez1
    @MaiconGonzalez1 3 роки тому

    very nice and everything but it did not work for me, difficult to put together the library as you are.

    • @mccormix
      @mccormix  3 роки тому +2

      Hello Maicon, sorry it didn't work for you. I intentionally move fast in the video so it doesn't get boring. If you let me know what error you are having maybe I can help.
      (Had to edit my comment as I thought you were replying regarding a paid product, whoops!)

  • @shehzadqadri1381
    @shehzadqadri1381 2 роки тому

    Its good . now also tell us how to change values from database.

    • @mccormix
      @mccormix  Рік тому

      It is not possible using this technique. You'll have to use the Google Sheets API.

  • @bilaltopuz9808
    @bilaltopuz9808 2 роки тому

  • @Elevationprint
    @Elevationprint Рік тому

    Doesnt seem to work now.

    • @mccormix
      @mccormix  Рік тому +1

      Yes they must have changed something on the server side unfortunately.

  • @daniel-hv4qy
    @daniel-hv4qy 2 роки тому

    Can someone please tell me what did i do wrong?

    • @mccormix
      @mccormix  2 роки тому

      Could you please describe your problem in more detail so that people can help you.

  • @StijnHommes
    @StijnHommes 2 роки тому

    You mean a static single page *website*. You know, the bit with the html extension.

  • @shopifypro
    @shopifypro 2 роки тому +1

    Subswibed