Drop table and recreate if exist in sqflite flutter2019 Community Moderator ElectionFlutter Sqflite multiple table modelsFlutter - How to update the table structure in Sqflite?How to do a database insert with SQFlite in FlutterHow to get the number of rows in a database table with Flutter SQFliteHow to do a database update with SQFlite in FlutterHow to do a database query with SQFlite in FlutterHow to create multiple tables in a database in sqflite?Flutter: How to load data in main.dart and sync json to sqfliteHow to get the total of column values in sqflite in flutter?How can I know if row is exist in flutter sqflite?

They call me Inspector Morse

Set and print content of environment variable in cmd.exe subshell?

Latest web browser compatible with Windows 98

Solving "Resistance between two nodes on a grid" problem in Mathematica

Is it possible to have an Abelian group under two different binary operations but the binary operations are not distributive?

Are babies of evil humanoid species inherently evil?

Does "variables should live in the smallest scope as possible" include the case "variables should not exist if possible"?

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Why is Beresheet doing a only a one-way trip?

What Happens when Passenger Refuses to Fly Boeing 737 Max?

Placing subfig vertically

Time travel short story where dinosaur doesn't taste like chicken

Fourth person (in Slavey language)

Things to avoid when using voltage regulators?

Are the terms "stab" and "staccato" synonyms?

Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?

Regex for certain words causes Spaces

How do I express some one as a black person?

Reverse string, can I make it faster?

How strictly should I take "Candidates must be local"?

Why the color red for the Republican Party

What are some noteworthy "mic-drop" moments in math?

Extra alignment tab has been changed to cr. } using table, tabular and resizebox

PTIJ: Why can't I eat anything?



Drop table and recreate if exist in sqflite flutter



2019 Community Moderator ElectionFlutter Sqflite multiple table modelsFlutter - How to update the table structure in Sqflite?How to do a database insert with SQFlite in FlutterHow to get the number of rows in a database table with Flutter SQFliteHow to do a database update with SQFlite in FlutterHow to do a database query with SQFlite in FlutterHow to create multiple tables in a database in sqflite?Flutter: How to load data in main.dart and sync json to sqfliteHow to get the total of column values in sqflite in flutter?How can I know if row is exist in flutter sqflite?










0















I want to drop table before populating server data if exist.



the Queries I'm trying



 deleteOptionTable() async 
final db = await database;
db.rawDelete("Delete * from option");

dropTable() async
final db = await database;
db.query('SELECT * FROM cloudnet360.db WHERE name =option and type=table');



I have tried something like this but nothing is happening.



void _insertOption(OptionsGroupList option) async 

int idd = dbHelper.dropTable();

print('DROP TABLE: $idd');

PreferencesConnector myprefs= PreferencesConnector();
String merchantid=await myprefs.readString('merchantid');
String hashkey=await myprefs.readString('hashkey');

Map<String, dynamic> row =
DatabaseHelper.columnGroupId:option.grouprowid ,
DatabaseHelper.columnGroupName: option.groupname,
DatabaseHelper.columnIsRequired:option.isrequired ,
DatabaseHelper.columnMerchantId: merchantid,
DatabaseHelper.columnMerchantHashKey: hashkey,
;
int id = await dbHelper.insertOption(row);

print('inserted option row id: $id');










share|improve this question






















  • Don't understand flutter but ... the select statement in dropTable() will drop the table??

    – AIMIN PAN
    Mar 7 at 7:46











  • @AIMINPAN I'm unable to drop the table .

    – farhana
    Mar 7 at 7:59











  • did you try int idd = await dbHelper.dropTable();? I assume it's async

    – TruongSinh
    Mar 7 at 11:16















0















I want to drop table before populating server data if exist.



the Queries I'm trying



 deleteOptionTable() async 
final db = await database;
db.rawDelete("Delete * from option");

dropTable() async
final db = await database;
db.query('SELECT * FROM cloudnet360.db WHERE name =option and type=table');



I have tried something like this but nothing is happening.



void _insertOption(OptionsGroupList option) async 

int idd = dbHelper.dropTable();

print('DROP TABLE: $idd');

PreferencesConnector myprefs= PreferencesConnector();
String merchantid=await myprefs.readString('merchantid');
String hashkey=await myprefs.readString('hashkey');

Map<String, dynamic> row =
DatabaseHelper.columnGroupId:option.grouprowid ,
DatabaseHelper.columnGroupName: option.groupname,
DatabaseHelper.columnIsRequired:option.isrequired ,
DatabaseHelper.columnMerchantId: merchantid,
DatabaseHelper.columnMerchantHashKey: hashkey,
;
int id = await dbHelper.insertOption(row);

print('inserted option row id: $id');










share|improve this question






















  • Don't understand flutter but ... the select statement in dropTable() will drop the table??

    – AIMIN PAN
    Mar 7 at 7:46











  • @AIMINPAN I'm unable to drop the table .

    – farhana
    Mar 7 at 7:59











  • did you try int idd = await dbHelper.dropTable();? I assume it's async

    – TruongSinh
    Mar 7 at 11:16













0












0








0








I want to drop table before populating server data if exist.



the Queries I'm trying



 deleteOptionTable() async 
final db = await database;
db.rawDelete("Delete * from option");

dropTable() async
final db = await database;
db.query('SELECT * FROM cloudnet360.db WHERE name =option and type=table');



I have tried something like this but nothing is happening.



void _insertOption(OptionsGroupList option) async 

int idd = dbHelper.dropTable();

print('DROP TABLE: $idd');

PreferencesConnector myprefs= PreferencesConnector();
String merchantid=await myprefs.readString('merchantid');
String hashkey=await myprefs.readString('hashkey');

Map<String, dynamic> row =
DatabaseHelper.columnGroupId:option.grouprowid ,
DatabaseHelper.columnGroupName: option.groupname,
DatabaseHelper.columnIsRequired:option.isrequired ,
DatabaseHelper.columnMerchantId: merchantid,
DatabaseHelper.columnMerchantHashKey: hashkey,
;
int id = await dbHelper.insertOption(row);

print('inserted option row id: $id');










share|improve this question














I want to drop table before populating server data if exist.



the Queries I'm trying



 deleteOptionTable() async 
final db = await database;
db.rawDelete("Delete * from option");

dropTable() async
final db = await database;
db.query('SELECT * FROM cloudnet360.db WHERE name =option and type=table');



I have tried something like this but nothing is happening.



void _insertOption(OptionsGroupList option) async 

int idd = dbHelper.dropTable();

print('DROP TABLE: $idd');

PreferencesConnector myprefs= PreferencesConnector();
String merchantid=await myprefs.readString('merchantid');
String hashkey=await myprefs.readString('hashkey');

Map<String, dynamic> row =
DatabaseHelper.columnGroupId:option.grouprowid ,
DatabaseHelper.columnGroupName: option.groupname,
DatabaseHelper.columnIsRequired:option.isrequired ,
DatabaseHelper.columnMerchantId: merchantid,
DatabaseHelper.columnMerchantHashKey: hashkey,
;
int id = await dbHelper.insertOption(row);

print('inserted option row id: $id');







android dart flutter sqflite






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 7:42









farhanafarhana

2,63552235




2,63552235












  • Don't understand flutter but ... the select statement in dropTable() will drop the table??

    – AIMIN PAN
    Mar 7 at 7:46











  • @AIMINPAN I'm unable to drop the table .

    – farhana
    Mar 7 at 7:59











  • did you try int idd = await dbHelper.dropTable();? I assume it's async

    – TruongSinh
    Mar 7 at 11:16

















  • Don't understand flutter but ... the select statement in dropTable() will drop the table??

    – AIMIN PAN
    Mar 7 at 7:46











  • @AIMINPAN I'm unable to drop the table .

    – farhana
    Mar 7 at 7:59











  • did you try int idd = await dbHelper.dropTable();? I assume it's async

    – TruongSinh
    Mar 7 at 11:16
















Don't understand flutter but ... the select statement in dropTable() will drop the table??

– AIMIN PAN
Mar 7 at 7:46





Don't understand flutter but ... the select statement in dropTable() will drop the table??

– AIMIN PAN
Mar 7 at 7:46













@AIMINPAN I'm unable to drop the table .

– farhana
Mar 7 at 7:59





@AIMINPAN I'm unable to drop the table .

– farhana
Mar 7 at 7:59













did you try int idd = await dbHelper.dropTable();? I assume it's async

– TruongSinh
Mar 7 at 11:16





did you try int idd = await dbHelper.dropTable();? I assume it's async

– TruongSinh
Mar 7 at 11:16












1 Answer
1






active

oldest

votes


















0














Indeed your dropTable method does not seem to actually drop any table:



To delete (drop) a table:



DROP TABLE IF EXISTS my_table


To clear a table content:



DELETE FROM my_table





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038488%2fdrop-table-and-recreate-if-exist-in-sqflite-flutter%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Indeed your dropTable method does not seem to actually drop any table:



    To delete (drop) a table:



    DROP TABLE IF EXISTS my_table


    To clear a table content:



    DELETE FROM my_table





    share|improve this answer



























      0














      Indeed your dropTable method does not seem to actually drop any table:



      To delete (drop) a table:



      DROP TABLE IF EXISTS my_table


      To clear a table content:



      DELETE FROM my_table





      share|improve this answer

























        0












        0








        0







        Indeed your dropTable method does not seem to actually drop any table:



        To delete (drop) a table:



        DROP TABLE IF EXISTS my_table


        To clear a table content:



        DELETE FROM my_table





        share|improve this answer













        Indeed your dropTable method does not seem to actually drop any table:



        To delete (drop) a table:



        DROP TABLE IF EXISTS my_table


        To clear a table content:



        DELETE FROM my_table






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 18:52









        alextkalextk

        1,8361220




        1,8361220





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038488%2fdrop-table-and-recreate-if-exist-in-sqflite-flutter%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229