No BCP command for Linux?
How do you BCP data from a file to a Sybase database in
a BCP-like fashion? I don't see a BCP command for Linux. Thanks ~ Bubnoff |
BCP is a Sybase tool, so you'd have to get a Linux version.
|
So there is no equivalent functionality?
I'm looking for equivalent functionality. I don't think there is a Linux
version of this tool ( I've looked ). There has to be some way to import tables from flat files into Sybase for Linux. Does anyone know of a BCP-type tool that can import a flat file into Sybase for Linux? Bubnoff |
It'd be easy enough to code something up in Perl using DBI, DBD::Sybase, I don't know if there's a prebuilt tool.
This is assuming you don't want Sybase on Linux, if I understand you correctly. If you do want Sybase on Linux http://www.sybase.com/linux. There's also Perl modules to front-end bcp http://search.cpan.org/~mewp/sybperl-2.18/BCP/BCP.pm |
Perl
I may end up using Perl as you suggest. Sybase's servers appear to be down
and it seems like a lot of overhead just to get bcp functionality. My main objection to Perl is that I've heard that it was fairly slow with large data tables. Has anyone used SQSH for this? I've read the man page several times but am a bit "green" with SQSH and was hoping there were some examples. It has a bcp command for transferring data from server to server but I don't see an option to use a file as input for bcp. Sorry if this sounds naive, Bubnoff |
Well, I wasn't sure whether you wanted BCP itself on Linux, which is available, or whether you preferred to do without and just wanted BCP type functionality.
Meant to ask that previously. Anyway, I've done a lot of Perl (utilising Oracle, Sybase, MySQL) and it's fairly swift; I'd say 80-90% as quick as C, all other things being equal. It is compiled on the fly, not interpreted. http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html The main bottleneck tends to be the DB at either or both ends. Obviously there are tricks like turning off indexes on the destn tables, doing inserts, then re-indexing. Faster than default of index being updated for each row as you go. You can have 2 db cxns open at the same time, so you can stream from one DB to the other. The main Perl docs are http://perldoc.perl.org/ http://www.perlmonks.org/?node=Tutorials if you need them. Anyway, HTH. |
Thanks for your patience ~ and thoughtful replies!
I really appreciate your replies and would be interested in any Perl
solutions you use. I'm familiar with Perl, I just haven't used Perl with Sybase. To be honest, I've always used SQSH and BASH to collect data into a file or sqlite db then Perl to manipulate the results. I've never quite understood how to use DBI and Perl with complex SQL statements involving cursors and whatnot. It's clumsy, I know, but I'm at the mercy of my lack of knowledge in this case. With SQSH you can just use your existing SQL code and go to town. I'm not sure how to translate cursors into Perl. I may ask the Monks. Also, I can't figure out which Sybase package contains bcp. I'll do more research on that ...the docs indicate a Windows version, but do not reference a Linux version. I've downloaded the SQLanywhere and will see what that contains. Thanks again ~ Bub |
Its a long time since I worked with Sybase, but for Sybase on Linux, start here http://www.sybase.com/linux.
If you've got any specific qns re Perl+DBI, post them and I'll see what code I've got. I haven't written a BCP replacement, but copying/streaming data from one DB to another isn't that hard ( usually :) ). |
you can also use Python. Here's a Sybase module for Python. In the docs, it talks about bulkcopy.
|
Here's what I've got, with a new issue. :(
I'm looking into a Perl module called Sybase::BCP. Here's what I've got
( straight out of the Sybase::BCP man page ): Code:
$bcp = new Sybase::BCP $user, $passwd, $server; standard BCP I see the data. I see the same amount of rows but all the fields are NULL. Here's some fake sample data formatted to the specs of the real data: Code:
"AARDVARK, GLOIN"|04|1770 FAKE ADDRESS|(509) 666-6666|0888888|114 Bubnoff |
Anything at all in BCP.err ?
Can you show us the whole program, sanitize user/passwd if you want? I take it you're looking at http://search.cpan.org/~mewp/sybperl-2.18/BCP/BCP.pm |
That's the code ( above ) minus the usual Perl boiler-plate at the top. The sample above is a sanitized version of what I'm using. This
is just a test to see if it's possible so I haven't done much except adjust what's in the man page to suit. Nothing shows up in the error log. I looked at the Perl Monks site where the author is known to frequent and he suggests trying BLK instead of BCP using the same syntax. The difference being the use of CTlib instead of DBlib. Unfortunately, it appears I have an incompatible CTlib version installed. Code:
This version of Sybase::CTlib doesn't support the CS_SERVERADDR property at /usr/local/lib/perl/5.8.8/Sybase/BLK.pm line 363. Bubnoff |
I'll have to give the Python module a try. Thanks for the suggestion.
I was looking for an excuse to bone up on my Python anyway. |
All times are GMT -5. The time now is 05:35 PM. |