ranjan_jajodia has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I am writing a perl script which will be reading a config file containing multiple database configurations, get a dump of the tables specified and store them in files. For reading config (xml) I am using XML::Simple which suits my needs pretty well. However I am stumped upon which module to use to connect to Sybase Databases and get data. My original intention was to use a wrapper module over Sybase BCP utility like Sybase::BCP or Sybase::Blk but looks like these modules do not support 'Out' operation. Is there any other module which I can use? What do experienced perl developers normally do to take dumps of database tables?
Regards,
Ranjan
Re: Getting Dump from Sybase Tables
by mpeppler (Vicar) on Jun 25, 2007 at 15:39 UTC
|
The easiest thing is to just call Sybase's bcp utility from your perl code. It's pretty simple to build the bcp command line based on the table names and then run it... It will also be the fastest solution.
Alternatively, as a bcp OUT operation is really just a select you could just do a simple select in any Sybase perl module (DBI/DBD::Sybase, Sybase::CTlib, etc) and write the results to a text file with the appropriate column separators (by default a TAB character).
Michael
| [reply] |
|
Hi Michael,
Calling the Sybase's bcp utility is definitely an option I am inclined to take currently. Thanks for the suggestion; I will go by it :)
From what I have seen select queries are way slower than bcp and I have quite a few large tables to take dumps from. So this might not be a good idea.
Regards,
Ranjan
| [reply] |
Re: Getting Dump from Sybase Tables
by whereiskurt (Friar) on Jun 25, 2007 at 16:13 UTC
|
superdoc,
I'm constantly using the 'FreeTDS Sybase' drivers to get stuff done. I don't know if you're on a linux box, if you are, and you're trying to connect to MSSQL boxes or native Sybase stuff, check this article out:
Getting Sybase/MSSQL Databases working with Perl DBI
In essence you get the FreeTDS stuff rocking, setup some aliases for your DB servers in a config file, and then use normal DBI to get stuff done.
Hope this helps.
Kurt
| [reply] |
|
| [reply] |
|