Initiating the pgsqlDump table list prior to backup

Initiating the pgsqlDump table list prior to backup

Postby kerrywales » Mon 17 May 2010 11:37

I have just started looking at the PgSqlDump class to use for backup.

My first attempt works. whey hey!!!

On one of my db's I have around 300 tables. I am looking to backup the data of all except one.

My thought was, rather than looping around all the table names and adding them to the Tables collection of the object I would initiate the object and remove the one table name.

The hover over help for the collection says that it "Gets and Sets" the tables.

Is there a way to tell it to "Get" all the tables prior to calling the Backup method?

If not should I lookup another Devart class to help me?

Kerry
kerrywales
 
Posts: 52
Joined: Tue 05 Jan 2010 12:26

Postby StanislavK » Tue 18 May 2010 14:10

Data from all tables will be backed up if the Tables property is not set. After that, you can remove the DML scripts for the table you don't need to be backed up.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby kerrywales » Wed 19 May 2010 08:53

Thank you for your reply.
I was looking to see if there was a method to auto populate the Tables collection.
I see from the sample code the ability to read in the Tables in the db which I can manipulate.
I also saw from the documentation pgSqlDumpObjects but cannot find in the documentation a way to use it.
Perhaps I can add the request as a wishlist item?
kerrywales
 
Posts: 52
Joined: Tue 05 Jan 2010 12:26

Postby StanislavK » Thu 20 May 2010 14:16

As I can understand, you wish to retrieve names of all tables available in the database, and construct the Tables property from them. Am I correct? For this purpose, the PgSqlConnection.GetSchema method can be used like in the following sample:
Code: Select all
StringBuilder sb = new StringBuilder();

DataTable dt = connection.GetSchema(PgSqlMetaDataCollectionNames.Tables);
foreach (DataRow dr in dt.Rows)
   sb.Append(dr["Name"]).Append(";");
     
PgSqlDump dump = new PgSqlDump(connection);
dump.Tables = sb.ToString();
dump.Backup(...);

For details on retrieving metadata, please see the corresponding topic of our documentation:
http://www.devart.com/dotconnect/postgresql/docs/MetaData.html

As for the PgSqlDumpObjects enumeration, it should be used as the value for the PgSqlDump.ObjectTypes property. It can be assigned as usual enumeration:
Code: Select all
pgSqlDump.ObjectTypes = PgSqlDumpObjects.Schemas | PgSqlDumpObjects.Users;

Feel free to contact us if something is unclear.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby kerrywales » Thu 20 May 2010 21:23

Thank you for the information. I will digest this tomorrow. It has been very helpful.
Regards
kerrywales
 
Posts: 52
Joined: Tue 05 Jan 2010 12:26


Return to dotConnect for PostgreSQL