How do I VACUUM a SQL database

General questions that have to do with plugins go here

How do I VACUUM a SQL database

Postby Redlion » Mon Jan 02, 2017 2:00 am

Hi,

I am playing with a very simple family tree program and wanted to clean up the database after all the updating.

I thought I could just use the SQL Vacuum command, but it does not work?

Here is the cut down code I am using, it is all that is needed to access the Database.

Code: Select all
function setup() ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    db = assert_userdata( sqlite3.open(Dir$.."FamilyData.sql") )
endfunction

function closedown() ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    assert_number( db:close() )
endfunction

function assert_number(f) ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if gettype(f) <> #number then debugprint("Assertion failed")
    return(f)
endfunction

function assert_userdata(f) ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if gettype(f) <> #userdata then debugprint("Assertion failed")
    return(f)
endfunction

function vacuum() ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    assert_number(db:exec("VACUUM"))
endfunction


setup()
vacuum()
closedown()


If anyone can suggest the correct syntax , that would move me on to the next challenge.

Thanks and Happy New Year to all.
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
Redlion
 
Posts: 62
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: How do I VACUUM a SQL database

Postby sinisrus » Tue Jan 03, 2017 1:08 pm

Can be that ?
TRUNCATE TABLE `nom_de_la_table`
sinisrus
 
Posts: 181
Joined: Tue Apr 21, 2015 5:43 pm

Re: How do I VACUUM a SQL database

Postby lazi » Tue Jan 03, 2017 3:16 pm

Try this:

db:exec("Vacuum")

As there is written https://sqlite.org/lang_vacuum.html it repacks the file to make it shorter. You can only see if it done anything, if there was e.g. deleted rows in the database.
User avatar
lazi
 
Posts: 218
Joined: Fri Feb 25, 2011 12:08 am


Return to General plugin questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron