No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Can anyone here have a tutorial how to create quasar framework with sqlite3 CRUD ?

    Help
    10
    11
    1334
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Stephen last edited by

      I’m creating a application that have a Sqlite , I can’t find any link that related to my needs. can anyone here give me a link.

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        sqlite is a database. You can’t use Quasar with it directly, since Quasar is a frontend framework. You’d need an API in front of the database.

        Or am I misunderstanding your question?

        Scott

        1 Reply Last reply Reply Quote 0
        • Hawkeye64
          Hawkeye64 last edited by

          You can use sqlite for mobile PWA apps? I think @Allan-EN-GB prefers to use PouchDB.

          1 Reply Last reply Reply Quote 0
          • Allan-EN-GB
            Allan-EN-GB Admin last edited by

            I use both. I prefer SQL actually but use pouch when required.

            Are you using building for mobile or for web? SQLite for browser isn’t a thing - It’s something you’d use in mobile mode and there is a plugin you can use for it.

            Let me know and I can provide some sample code.

            F O 2 Replies Last reply Reply Quote 0
            • F
              fedee13 @Allan-EN-GB last edited by fedee13

              @Allan-EN-GB Would you mind sharing a sample code? I’m trying to develop a mobile app with Quasar+Cordova but I don’t know where to initialize cordova-sqlite-storage.
              In a previous app I made what I did was before creating the Vue instance in main.js I initialize my database (WebSQL for browser and SQLite for native with cordova-sqlite-storage), should I do the same but with a db.js file inside /boot?

              const DB_NAME = "DemoQuasar.db";
              let myDatabase = null;
              
              function openConnection() {
                return new Promise((resolve, reject) => {
                  try {
                    if (window.cordova.platformId === "browser") {
                      myDatabase = window.openDatabase(
                        DB_NAME,
                        "1.0",
                        "database",
                        2 * 1024 * 1024
                      );
                      resolve();
                    } else {
                      window.sqlitePlugin.openDatabase(
                        {
                          name: DB_NAME,
                          location: "default"
                        },
                        function(db) {
                          myDatabase = db;
                          resolve();
                        }
                      );
                    }
                  } catch (error) {
                    reject(error);
                  }
                });
              }
              
              function initializeDatabase() {
                return new Promise((resolve, reject) => {
                  try {
                    openConnection().then(() => {
                      myDatabase.transaction(
                        function(tx) {
                          tx.executeSql(
                            "CREATE TABLE IF NOT EXISTS Demo\
                            (\
                              Campo1 TEXT NOT NULL,\
                              Campo2 TEXT NOT NULL,\
                              Campo3 TEXT NULL\
                            )"
                          );
                        },
                        error => {
                          // eslint-disable-next-line no-console
                          console.log("Transaction ERROR: " + error.message);
                          throw new Error(error.message);
                        },
                        function() {
                          // eslint-disable-next-line no-console
                          console.log("Initialize OK");
                          resolve();
                        }
                      );
                    }),
                      error => {
                        throw new Error(
                          "Hubo un problem al inicializar la base de datos: " +
                            JSON.stringify(error)
                        );
                      };
                  } catch (error) {
                    reject(error);
                  }
                });
              }
              
              // eslint-disable-next-line no-unused-vars
              export default async ({ app, router, store, Vue }) => {
                await initializeDatabase();
              };
              
              export { myDatabase };
              

              And then in Index.vue (just to check if is it working or not):

              <script>
              import { myDatabase } from "../boot/db";
              export default {
                name: "PageIndex",
                mounted() {
                  myDatabase.transaction(
                    function(tx) {
                      tx.executeSql(
                        "INSERT INTO Demo VALUES (?1,?2,?3)",
                        ["Codigo1", "Codigo2", "Codigo3"],
                        function(tx, res) {
                          alert(res.insertId);
                        }
                      );
                    },
                    function(error) {
                      alert(error);
                    },
                    function() {
                      // eslint-disable-next-line no-console
                      console.log("insert Demo OK");
                    }
                  );
                }
              };
              </script>
              

              edit: example code

              1 Reply Last reply Reply Quote 0
              • O
                omgwalt @Allan-EN-GB last edited by

                @Allan-EN-GB I would be very interested in seeing your sample code, Allan!

                1 Reply Last reply Reply Quote 0
                • king_of_leon
                  king_of_leon last edited by

                  I was too looking for this

                  1 Reply Last reply Reply Quote 0
                  • C
                    cynderkromi last edited by cynderkromi

                    I am also looking for a tutorial about using Quasar (Vue/Electron) with SQLite, too. I want to develop a desktop application.

                    T 1 Reply Last reply Reply Quote 0
                    • T
                      technowebs @cynderkromi last edited by

                      @cynderkromi Have you found any tutorial or sample code? I need to develop an app with SQLite that works on mobile and desktops(Windows or Linux).

                      C 1 Reply Last reply Reply Quote 0
                      • C
                        cynderkromi @technowebs last edited by

                        @technowebs I haven’t. I started using IndexedDB with localbase, but I’m not sure if IndexedDB has the data integrity that I need.

                        1 Reply Last reply Reply Quote 0
                        • L
                          ly last edited by

                          for me:
                          1 get sqlite3 from npm and vs2019 with c++ dev pack and python2 installed for compiling thing.
                          2 xx.db file in electron “user data” path.
                          db.js under src-electron folder(main process). CRUD thing is done here.
                          3 ipcRender under src( render process) and mainWindow.webcontent under src-electron(main process) to call db.js i mentioned above and sometimes get its callback data.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post