Page 1 of 1

restore_db

PostPosted: Tue Sep 13, 2011 6:05 am
by rogel
hi!

I am writing an method to restore the database tables. my input is a zip file that contains the data(insert scripts). I am not allowed to use pgAdmin. What is the best approach insert these data in the database and synchronize the sequences?

e.g.
table:address
column:
idaddress (servoy_seq)
street
city

script to execeute:
INSERT INTO address (idaddress, street, city) VALUES (8, '2 Rawson Street', 'Sydney');
where 8 is from the idaddress when the backup was performed.

Re: restore_db

PostPosted: Tue Sep 13, 2011 9:36 am
by mboegem
rogel wrote:script to execeute:
INSERT INTO address (idaddress, street, city) VALUES (8, '2 Rawson Street', 'Sydney');
where 8 is from the idaddress when the backup was performed.


you can execute this SQL directly via the RawSQL plugin (shipped by default)
Be careful when reading the textfile: huge textfiles can make you hit the max of memory available.

As for synchronizing the sequences: I'm not familiar with that, as I never use the servoy sequences...
Anyone else on this?

Re: restore_db

PostPosted: Wed Sep 14, 2011 9:26 pm
by rogel
mboegem wrote:
rogel wrote:script to execeute:
INSERT INTO address (idaddress, street, city) VALUES (8, '2 Rawson Street', 'Sydney');
where 8 is from the idaddress when the backup was performed.


you can execute this SQL directly via the RawSQL plugin (shipped by default)
Be careful when reading the textfile: huge textfiles can make you hit the max of memory available.

As for synchronizing the sequences: I'm not familiar with that, as I never use the servoy sequences...
Anyone else on this?

Thanks Marc. What would you suggest a better way to read the SQL file than readTextFile?

Re: restore_db

PostPosted: Thu Sep 15, 2011 10:24 am
by ROCLASI
rogel wrote:What would you suggest a better way to read the SQL file than readTextFile?

Take a look at this old post.
viewtopic.php?f=3&t=6485


Hope this helps.

Re: restore_db

PostPosted: Fri Sep 16, 2011 1:13 am
by rogel
ROCLASI wrote:
rogel wrote:What would you suggest a better way to read the SQL file than readTextFile?

Take a look at this old post.
https://forum.servoy.com/viewtopic.php?f=3&t=6485


Hope this helps.


Helpful. Thanks! =)

What if the file is in XML format with nodes of tablename and columns? I am stuck with using readTxtFile(). Any other suggestion?

Code: Select all
<statelist><state><id>1</id><code>nsw</code><name>new south wales</name></state></statelist>