LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-10-2009, 06:23 PM   #1
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Rep: Reputation: 16
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
 
Old 11-10-2009, 07:20 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
BCP is a Sybase tool, so you'd have to get a Linux version.
 
Old 11-10-2009, 10:12 PM   #3
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Original Poster
Rep: Reputation: 16
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
 
Old 11-11-2009, 12:14 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
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
 
Old 11-11-2009, 05:09 PM   #5
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Original Poster
Rep: Reputation: 16
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
 
Old 11-11-2009, 08:02 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
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.
 
Old 11-12-2009, 01:05 PM   #7
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Original Poster
Rep: Reputation: 16
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
 
Old 11-12-2009, 07:46 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
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 ).
 
Old 11-12-2009, 08:25 PM   #9
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
you can also use Python. Here's a Sybase module for Python. In the docs, it talks about bulkcopy.
 
Old 11-12-2009, 09:34 PM   #10
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Original Poster
Rep: Reputation: 16
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;
$bcp->config(INPUT => 'testStud2.bcp',
             OUTPUT => 'tempdb..agStudDB',
             FIELDS => 6,
             SEPARATOR => '|',
             ERRORS => 'BCP.err');
$bcp->run;
Problem is when I look at the table I see nothing but NULL. If I use
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
"AARDVARK, CHOMPERS"|06|1770 FAKE ADDRESS|(509) 665-6666|0999999|212
Any thoughts?

Bubnoff
 
Old 11-12-2009, 09:57 PM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
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
 
Old 11-12-2009, 10:17 PM   #12
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Original Poster
Rep: Reputation: 16
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.
It looks like I may be stuck with bcp or an insert statement.

Bubnoff
 
Old 11-14-2009, 07:56 PM   #13
bubnoff
Member
 
Registered: Jun 2009
Location: Northwest
Distribution: Slackware
Posts: 43

Original Poster
Rep: Reputation: 16
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM
PPP Bridging Control Protocol (BCP) for Linux 2.4 or 2.6 cttran Linux - Networking 0 03-29-2006 05:41 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration