PDA

View Full Version : SQLite dump


azmanar
12-29-2005, 12:43 PM
Hi,

Does anyone have SQLite AMS snippets on:

1. Dump SQLite data to a CSV or .txt
2. Get CSV or .txt to SQLite.

Thanks

Roboblue
12-29-2005, 04:24 PM
Do you have the sqlite browser?
if not, go HERE (http://prdownloads.sourceforge.net/sqlitebrowser/sqlitebrowser-1.1-win.zip?download) and get the 1.1 version. I believe it is the 1.1 version of sqlite that is being used in AMS.
This can inport and export csv/txt.

Byte
12-30-2005, 02:36 AM
hi,

for csv to sql you can look here http://www.indigorose.com/forums/showthread.php?t=9832
helped me alot too.

for export sql to csv you can use something like this


--perform the query
local tbResults = SQLite.QueryToTable(db, "SELECT Name, Street, Zip, City FROM adressen");

--build the first line in csv
strCSV = "Name;Street;Zip;City\r\n";

--add one line for each record in db
for nRow = 1, tbResults2.Rows do
strCSV = strCSV..tbResults2.Data[nRow]["Name"]..";"..tbResults2.Data[nRow]["Street"]..";"..tbResults2.Data[nRow]["Zip"]..";"..tbResults2.Data[nRow]["City"].."\r\n";
end

--write textfile to disk
TextFile.WriteFromString(_SourceFolder.."\\Autoplay\\Docs\\", strCSV, false);


byte

azmanar
12-30-2005, 04:09 AM
Do you have the sqlite browser?
if not, go HERE (http://prdownloads.sourceforge.net/sqlitebrowser/sqlitebrowser-1.1-win.zip?download) and get the 1.1 version. I believe it is the 1.1 version of sqlite that is being used in AMS.
This can inport and export csv/txt.

Hi,

This is an excellent SQLite Browser. No install required at all, which is fantastic.

Now I have 2 choices:

1. Include this SQL browser in the AMS app, to
> to backup data
> to dump into SQL format in order to load in MYSQL over the net
> to dump in CSV in to order to load intoOpenOffice and MS Excel

2. Learn how SQLite Browser dump data, so that I can use the codes and include it in AMS. Thus no longer need SQLite browser to do choice 1.

Thanks Robo!!!

azmanar
12-30-2005, 04:16 AM
hi,

for csv to sql you can look here http://www.indigorose.com/forums/showthread.php?t=9832
helped me alot too.

for export sql to csv you can use something like this


--perform the query
local tbResults = SQLite.QueryToTable(db, "SELECT Name, Street, Zip, City FROM adressen");

--build the first line in csv
strCSV = "Name;Street;Zip;City\r\n";

--add one line for each record in db
for nRow = 1, tbResults2.Rows do
strCSV = strCSV..tbResults2.Data[nRow]["Name"]..";"..tbResults2.Data[nRow]["Street"]..";"..tbResults2.Data[nRow]["Zip"]..";"..tbResults2.Data[nRow]["City"].."\r\n";
end

--write textfile to disk
TextFile.WriteFromString(_SourceFolder.."\\Autoplay\\Docs\\", strCSV, false);


byte


Danke vielmal, Byte !!

This helps me to figure out the logic of the dump operations. woo hooo !!!

Thanks again.