restore_db

Questions, tips and tricks and techniques for scripting in Servoy

restore_db

Postby rogel » Tue Sep 13, 2011 6:05 am

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.
rogel
 
Posts: 264
Joined: Mon Jul 04, 2011 9:09 am

Re: restore_db

Postby mboegem » Tue Sep 13, 2011 9:36 am

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?
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1531
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: restore_db

Postby rogel » Wed Sep 14, 2011 9:26 pm

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?
rogel
 
Posts: 264
Joined: Mon Jul 04, 2011 9:09 am

Re: restore_db

Postby ROCLASI » Thu Sep 15, 2011 10:24 am

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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5342
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: restore_db

Postby rogel » Fri Sep 16, 2011 1:13 am

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>
rogel
 
Posts: 264
Joined: Mon Jul 04, 2011 9:09 am


Return to Methods

Who is online

Users browsing this forum: No registered users and 1 guest

cron