Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
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 ).
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:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.