tekartik / sqflite

SQLite flutter plugin
BSD 2-Clause "Simplified" License
2.86k stars 521 forks source link

Sqflitecommonffi not working in release mode #1077

Closed himanshuchaurasiya24 closed 7 months ago

himanshuchaurasiya24 commented 8 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

stan-at-work commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

himanshuchaurasiya24 commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

  • Have you tried copying sqlite3.dll to the root of the output folder (after build).
  • When debugging you need to add the sqlite3.dll sqlite file to your /windows folder

Can you please make a video tutorial on that if you have done that

stan-at-work commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

  • Have you tried copying sqlite3.dll to the root of the output folder (after build).
  • When debugging you need to add the sqlite3.dll sqlite file to your /windows folder

Can you please make a video tutorial on that if you have done that I can't make a video but i can give you this:

image

Download the sqlite3.dll file from HERE

himanshuchaurasiya24 commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

  • Have you tried copying sqlite3.dll to the root of the output folder (after build).
  • When debugging you need to add the sqlite3.dll sqlite file to your /windows folder

Can you please make a video tutorial on that if you have done that I can't make a video but i can give you this:

image

Download the sqlite3.dll file from HERE

Please share your database helper class

stan-at-work commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

  • Have you tried copying sqlite3.dll to the root of the output folder (after build).
  • When debugging you need to add the sqlite3.dll sqlite file to your /windows folder

Can you please make a video tutorial on that if you have done that I can't make a video but i can give you this:

image Download the sqlite3.dll file from HERE

Please share your database helper class

I don't know you mean with a database helper class.

If this fixed your issue please close the issue, And assign the answer.

himanshuchaurasiya24 commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

  • Have you tried copying sqlite3.dll to the root of the output folder (after build).
  • When debugging you need to add the sqlite3.dll sqlite file to your /windows folder

Can you please make a video tutorial on that if you have done that I can't make a video but i can give you this:

image Download the sqlite3.dll file from HERE

Please share your database helper class

I don't know you mean with a database helper class.

  • What does this contribute to the question ?

If this fixed your issue please close the issue, And assign the answer.

I mean you must have a database logic where you have initiated the database like db.execute(); , and initDB(); Like these This will help me to figure out if I'm doing wrong in these methods You can make a dummy database class if you don't want to share it from your project..

stan-at-work commented 7 months ago

Hey there, Can anyone make a detailed video of how can we make sqflitecommonffi work in release mode I have tried following the steps mentioned here and also from the google but of no use I guess I'm missing something. If anyone can please make a video and paste the link here it will be a great help for everyone.

  • Have you tried copying sqlite3.dll to the root of the output folder (after build).
  • When debugging you need to add the sqlite3.dll sqlite file to your /windows folder

Can you please make a video tutorial on that if you have done that I can't make a video but i can give you this:

image Download the sqlite3.dll file from HERE

Please share your database helper class

I don't know you mean with a database helper class.

  • What does this contribute to the question ?

If this fixed your issue please close the issue, And assign the answer.

I mean you must have a database logic where you have initiated the database like db.execute(); , and initDB(); Like these This will help me to figure out if I'm doing wrong in these methods You can make a dummy database class if you don't want to share it from your project..

This has nothing to do with this question: https://github.com/tekartik/sqflite/issues/1077#issue-2108330683

Currently i don't the time and resources to do that.

Please close the issue if your main issue is fixed

stan-at-work commented 7 months ago

@himanshuchaurasiya24 Could you accept the answer, so other people see what helped ?

himanshuchaurasiya24 commented 7 months ago

@himanshuchaurasiya24 Could you accept the answer, so other people see what helped ?

Well can you show me how you find the path for the database for windows that may help in solving the issue...

stan-at-work commented 7 months ago

@himanshuchaurasiya24 Could you accept the answer, so other people see what helped ?

Well can you show me how you find the path for the database for windows that may help in solving the issue...

I set the path to my database using;

    final databaseName = 'database.sqlite';
    final databaseDir = await getApplicationSupportDirectory();
    final databasePath = join(databaseDir.path, databaseName);

    ...

    if (Platform.isWindows || Platform.isLinux) {
      sqfliteFfiInit();

      database = await databaseFactoryFfi.openDatabase(
        databasePath,
        options: OpenDatabaseOptions(
          version: LocalDatabase.kVersion,
          onCreate: (Database database, int version) async {
            debugPrint('1: [On Create]: ${database.path}');
            debugPrint('2: Creating tables');
            await _createTables(db: database);
            debugPrint('3: Creating created !');
          },
          onOpen: (Database database) => database.execute('PRAGMA foreign_keys = ON;'),
        ),
      );
    } else if (Platform.isAndroid || Platform.isIOS || Platform.isMacOS) {
      database = await openDatabase(
        databasePath,
        version: LocalDatabase.kVersion,
        onCreate: (Database database, int version) async {
          debugPrint('1: [On Create]: ${database.path}');
          debugPrint('2: Creating tables');
          await _createTables(db: database);
          debugPrint('3: Creating created !');
        },

        //* This allows cascading delete on foreign keys
        onOpen: (Database database) => database.execute('PRAGMA foreign_keys = ON;'),
      );
    }
...

If you want the physical location with my configuration it will be saved in; C:\Users\USER\AppData\Roaming\APPNAME\APPNAME

himanshuchaurasiya24 commented 7 months ago

I will

@himanshuchaurasiya24 Could you accept the answer, so other people see what helped ?

Well can you show me how you find the path for the database for windows that may help in solving the issue...

I set the path to my database using;

    final databaseName = 'database.sqlite';
    final databaseDir = await getApplicationSupportDirectory();
    final databasePath = join(databaseDir.path, databaseName);

    ...

    if (Platform.isWindows || Platform.isLinux) {
      sqfliteFfiInit();

      database = await databaseFactoryFfi.openDatabase(
        databasePath,
        options: OpenDatabaseOptions(
          version: LocalDatabase.kVersion,
          onCreate: (Database database, int version) async {
            debugPrint('1: [On Create]: ${database.path}');
            debugPrint('2: Creating tables');
            await _createTables(db: database);
            debugPrint('3: Creating created !');
          },
          onOpen: (Database database) => database.execute('PRAGMA foreign_keys = ON;'),
        ),
      );
    } else if (Platform.isAndroid || Platform.isIOS || Platform.isMacOS) {
      database = await openDatabase(
        databasePath,
        version: LocalDatabase.kVersion,
        onCreate: (Database database, int version) async {
          debugPrint('1: [On Create]: ${database.path}');
          debugPrint('2: Creating tables');
          await _createTables(db: database);
          debugPrint('3: Creating created !');
        },

        //* This allows cascading delete on foreign keys
        onOpen: (Database database) => database.execute('PRAGMA foreign_keys = ON;'),
      );
    }
...

If you want the physical location with my configuration it will be saved in; C:\Users\USER\AppData\Roaming\APPNAME\APPNAME

Thank you for this code I'll check if it works for me