Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-19 Thread Johan Scheepers
Hi Frank,
Again you put a lot of effort in this
This is very much appreciated at this end.
I will look into this and try to comprehend
THANKS
Enjoy
Johan

- Original Message - 
From: Frank Bax [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, July 19, 2003 3:44 PM
Subject: Re: [newbie] DbaseIV database to use in Mandrake 9.1


 At 12:42 PM 7/18/03, Johan Scheepers wrote:
 This is one comprehensive response - of course all of it way over my
head -
 will need some close study.
 Sorry - would you maybe know any Howto's or sites or whatever to assist
me,
 please.


 Johan:  It's been about a year since I wrote/modified the script I posted,
 and it was on a *bsd system, so installation of DBI  DBD packages on MDK
 will be different.  In any case, I found these rpm's on the MDK 9.1 cd's:
 cd1 - perl-DBI-1.32-1mdk.i586.rpm
 cd1 - perl-Mysql-1.22_19-6mdk.i586.rpm
 cd3 - perl-DBD-Pg-1.21-2mdk.i586.rpm

 Don't install both mysql and pg rpm's.  Pick the one matching your
existing
 database.

 Although the perl-mysql rpm does have DBD in its name, the version number
 matches the (Oct2001) file at cpan.org (the next update was last month):
 http://search.cpan.org/author/JWIED/Msql-Mysql-modules-1.2219/

 Now for the dBase part (called xBase to cover other compatible file
 formats).  Here's some doc...
 http://search.cpan.org/author/JANPAZ/DBD-XBase-0.234/lib/DBD/XBase.pm
 Download:
 http://search.cpan.org/CPAN/authors/id/J/JA/JANPAZ/DBD-XBase-0.234.tar.gz
 After download:
  tar xfz DBD-XBase-0.234.tar.gz
  cd DBD-XBase-0.234
  perl Makefile.PL
  make
  make test
  make install
 All these commands except make install can be run as a 'normal' user,
you
 must be 'root' for the last step.  At this point, you should be able to
run
 the script I posted.

 As for howto webpages, I don't have any.  A google of perl dbd xbase did
 come up with an rpm for the dbd:xbase package on first hit.  A little
 further down, there is even one from MDK:

http://rpms.mandrakeclub.com/rpms/mandrake-devel/contrib/alpha/perl-DBD-XBase-0.232-1mdk.noarch.html

 Maybe it's a simple as install of 3 rpms?

 Frank









 Want to buy your Pack or Services from MandrakeSoft?
 Go to http://www.mandrakestore.com



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-18 Thread Frank Bax
At 02:33 PM 7/16/03, rikona wrote:
I have some old dbase files I may convert too. If you get
this to work, please post the result here. Thanks.
I have a perl script (from my *bsd system, but should work on Linux) that 
converts all dBase files in a directory to pgsql tables, you should be able 
to convert to mysql with different libraries.  You'll need to install:
DBI - abstraction layer for database access from perl
DBD::XBase - access to DBF files via DBI - include a program to dump structure
DBD::Pg or DBI:MySQL - access to database from DBI

For Mysql, you may need to change DBF2PG subroutine for translating 
datatypes; otherwise, just rewrite the mainline for your own purposes.

The script is written to take a parameter - if this is a filename (without 
extension), then it will process just that file, otherwise, every file 
starting with those characters.

Frank

- - - - -
#!/usr/bin/perl -w
use strict;
use File::Basename; # for basename() function
use DBI;  use DBD::XBase;  use DBD::Pg;
my $base = shift;

my $dir = '/home/fbax/DBFfiles/' . $base;
my $dbf = DBI-connect(dbi:XBase:$dir, {RaiseError = 1} );
my $dbp = DBI-connect(dbi:Pg:dbname=famtree, famtree, , {RaiseError 
= 1} );

while (my $fname = $dir/$base*.DBF) {
  DBF2PG ($dbf, $dbp, $fname, basename(substr($fname, 0, 
length($fname)-4)));
}

$dbf-disconnect;
$dbp-disconnect;
sub DBF2PG {
  (my $dbf, my $dbp, my $fname, my $table) = @_;
  $table = lc(\$table\);
  print $fname - $table\n;
  open (PIPE, dbfdump --info $fname |) or die Can't open $fname: $!;
  my $sql = CREATE TABLE $table ;
  my $sep = (;
  while( PIPE ) {
chomp;
if (/^[0-9]+\./) {  # line starts with number.
# print $_\n;
  my @stru = split; # stru contains field,type,len,dec
  $sql .= $sep.' '.lc($stru[1]).'';
  if ($stru[2] eq 'D') {
$sql .=  date;
  } elsif ($stru[2] eq 'L') {
$sql .=  boolean;
  } elsif ($stru[2] eq 'M') {
$sql .=  text;
  } elsif ($stru[2] eq 'G') {
$sql .=  text;
  } elsif ($stru[2] eq 'C'  $stru[3] eq 1) {
$sql .=  char;
  } elsif ($stru[2] eq 'C') {
$sql .=  varchar($stru[3]);
  } elsif ($stru[2] eq 'N'  $stru[4] eq 0  $stru[3]  5) {
$sql .=  int2;
  } elsif ($stru[2] eq 'N'  $stru[4] eq 0  $stru[3]  10) {
$sql .=  int4;
  } elsif ($stru[2] eq 'N'  $stru[4] eq 0) {
$sql .=  int8;
  } elsif ($stru[2] eq 'N') {
$sql .=  numeric($stru[3],$stru[4]);
  } else {
$sql .=  $stru[2].$stru[3].$stru[4];
  }
  $sep = ',';
}
  }
  close (PIPE);
  $sql .= ' );';
  $dbp-{RaiseError} = 0;
  $dbp-do( DROP TABLE $table );
  $dbp-{RaiseError} = 1;
  $dbp-do( $sql );
  my $sth = $dbf-prepare( SELECT * FROM .basename($fname) );
  $sth-execute;
  while (my @row = $sth-fetchrow_array()) {
$sql = INSERT INTO $table VALUES ;
$sep = (;
foreach my $fld (@row) {
  $sql .= $sep .$dbp-quote($fld);
  $sep = ,;
}
$sql .= ' );';
$dbp-do( $sql );
  }
  $sth-finish;
}

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-18 Thread Johan Scheepers
Hi Frank,
Thanks.
This is one comprehensive response - of course all of it way over my head -
will need some close study.
Sorry - would you maybe know any Howto's or sites or whatever to assist me,
please.
Enjoy
Johan.
***
- Original Message - 
From: Frank Bax [EMAIL PROTECTED]
To: newbie [EMAIL PROTECTED]
Cc: rikona [EMAIL PROTECTED]; Johan Scheepers
[EMAIL PROTECTED]
Sent: Friday, July 18, 2003 3:49 PM
Subject: Re: [newbie] DbaseIV database to use in Mandrake 9.1


 At 02:33 PM 7/16/03, rikona wrote:
  I have some old dbase files I may convert too. If you get
  this to work, please post the result here. Thanks.

 I have a perl script (from my *bsd system, but should work on Linux) that
 converts all dBase files in a directory to pgsql tables, you should be
able
 to convert to mysql with different libraries.  You'll need to install:
 DBI - abstraction layer for database access from perl
 DBD::XBase - access to DBF files via DBI - include a program to dump
structure
 DBD::Pg or DBI:MySQL - access to database from DBI

 For Mysql, you may need to change DBF2PG subroutine for translating
 datatypes; otherwise, just rewrite the mainline for your own purposes.

 The script is written to take a parameter - if this is a filename (without
 extension), then it will process just that file, otherwise, every file
 starting with those characters.

 Frank

 - - - - -
 #!/usr/bin/perl -w
 use strict;
 use File::Basename; # for basename() function
 use DBI;  use DBD::XBase;  use DBD::Pg;

 my $base = shift;

 my $dir = '/home/fbax/DBFfiles/' . $base;
 my $dbf = DBI-connect(dbi:XBase:$dir, {RaiseError = 1} );
 my $dbp = DBI-connect(dbi:Pg:dbname=famtree, famtree, , {RaiseError
 = 1} );

 while (my $fname = $dir/$base*.DBF) {
DBF2PG ($dbf, $dbp, $fname, basename(substr($fname, 0,
 length($fname)-4)));
 }

 $dbf-disconnect;
 $dbp-disconnect;

 sub DBF2PG {
(my $dbf, my $dbp, my $fname, my $table) = @_;
$table = lc(\$table\);
print $fname - $table\n;
open (PIPE, dbfdump --info $fname |) or die Can't open $fname: $!;
my $sql = CREATE TABLE $table ;
my $sep = (;
while( PIPE ) {
  chomp;
  if (/^[0-9]+\./) { # line starts with number.
 # print $_\n;
my @stru = split; # stru contains field,type,len,dec
$sql .= $sep.' '.lc($stru[1]).'';
if ($stru[2] eq 'D') {
  $sql .=  date;
} elsif ($stru[2] eq 'L') {
  $sql .=  boolean;
} elsif ($stru[2] eq 'M') {
  $sql .=  text;
} elsif ($stru[2] eq 'G') {
  $sql .=  text;
} elsif ($stru[2] eq 'C'  $stru[3] eq 1) {
  $sql .=  char;
} elsif ($stru[2] eq 'C') {
  $sql .=  varchar($stru[3]);
} elsif ($stru[2] eq 'N'  $stru[4] eq 0  $stru[3]  5) {
  $sql .=  int2;
} elsif ($stru[2] eq 'N'  $stru[4] eq 0  $stru[3]  10) {
  $sql .=  int4;
} elsif ($stru[2] eq 'N'  $stru[4] eq 0) {
  $sql .=  int8;
} elsif ($stru[2] eq 'N') {
  $sql .=  numeric($stru[3],$stru[4]);
} else {
  $sql .=  $stru[2].$stru[3].$stru[4];
}
$sep = ',';
  }
}
close (PIPE);
$sql .= ' );';
$dbp-{RaiseError} = 0;
$dbp-do( DROP TABLE $table );
$dbp-{RaiseError} = 1;
$dbp-do( $sql );

my $sth = $dbf-prepare( SELECT * FROM .basename($fname) );
$sth-execute;
while (my @row = $sth-fetchrow_array()) {
  $sql = INSERT INTO $table VALUES ;
  $sep = (;
  foreach my $fld (@row) {
$sql .= $sep .$dbp-quote($fld);
$sep = ,;
  }
  $sql .= ' );';
  $dbp-do( $sql );
}
$sth-finish;
 }









 Want to buy your Pack or Services from MandrakeSoft?
 Go to http://www.mandrakestore.com



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-16 Thread rikona
Hello Johan,

Monday, July 14, 2003, 1:03:10 PM, you wrote:

JS I have this dbase IV database which I use in Delphi 3.

JS Can this DBF used in mdk9.1.

I just ran across a viewer and converter for dbase files. It is
dbview, and is in the contrib group. You may be able to convert the
dbase files to some other format with this.

I have some old dbase files I may convert too. If you get this to
work, please post the result here. Thanks.

-- 
HTH,
 rikonamailto:[EMAIL PROTECTED]


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


[newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Johan Scheepers
Hi
I have this dbase IV database which I use in Delphi 3.

Can this DBF used in mdk9.1.

Maybe how?

Kylix3?

I would really appreciate some pointers here please.

Enjoy
Johan

May this be a good day for learning

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Stephen Kuhn
On Tue, 2003-07-15 at 06:03, Johan Scheepers wrote:
 Hi
 I have this dbase IV database which I use in Delphi 3.
 
 Can this DBF used in mdk9.1.
 
 Maybe how?
 
 Kylix3?
 
 I would really appreciate some pointers here please.
 
 Enjoy
 Johan
 
 May this be a good day for learning

Can't the database be sucked into MySQL and then used after that?

-- 
Tue Jul 15 07:10:01 EST 2003
 07:10:01 up 23:13,  2 users,  load average: 0.24, 0.35, 0.36
-
|____  |kuhn media australia|
|   /-oo /| |'-.   |http://kma.0catch.com   |
|  .\__/ || |   |  ||
|   _ /  `._ \|_|_.-'  |stephen kuhn|
|  | /  \__.`=._) (_   | email: [EMAIL PROTECTED] |
-
  linux user #:267497 linux machine #:194239 * MDK 9.1+  RH 9  
  Mandrake Linux Kernel 2.4.21-11mdk Cooker for i586
-
 * This message was composed on a 100% Microsoft free computer *

Most people need some of their problems to help take their mind off
some of the others.

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Stephen Kuhn
On Tue, 2003-07-15 at 07:42, JoeHill wrote:
 On 15 Jul 2003 07:10:32 +1000
 Stephen Kuhn [EMAIL PROTECTED] uttered:
 
  sucked into MySQL
 
 ouch! should you have your sql checked for blockages after?

Hell, a purge dunt hurt no one!

-- 
Tue Jul 15 08:00:00 EST 2003
 08:00:00 up 1 day, 3 min,  2 users,  load average: 0.68, 0.49, 0.42
-
|____  |kuhn media australia|
|   /-oo /| |'-.   |http://kma.0catch.com   |
|  .\__/ || |   |  ||
|   _ /  `._ \|_|_.-'  |stephen kuhn|
|  | /  \__.`=._) (_   | email: [EMAIL PROTECTED] |
-
  linux user #:267497 linux machine #:194239 * MDK 9.1+  RH 9  
  Mandrake Linux Kernel 2.4.21-11mdk Cooker for i586
-
 * This message was composed on a 100% Microsoft free computer *

Natural laws have no pity.

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread aron smith
On Mon, 2003-07-14 at 15:02, Stephen Kuhn wrote:
 On Tue, 2003-07-15 at 07:42, JoeHill wrote:
  On 15 Jul 2003 07:10:32 +1000
  Stephen Kuhn [EMAIL PROTECTED] uttered:
  
   sucked into MySQL
  
  ouch! should you have your sql checked for blockages after?
 
 Hell, a purge dunt hurt no one!
It's up yehaa


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread John Wilson
On July 14, 2003 01:03 pm, Johan Scheepers wrote:
 Hi
 I have this dbase IV database which I use in Delphi 3.

 Can this DBF used in mdk9.1.

 Maybe how?

 Kylix3?

 I would really appreciate some pointers here please.

 Enjoy
 Johan

 May this be a good day for learning

Klyix will do nicely.

And don't mind Stephen..he's just ranting because he had to find something 
else to do than read the list this weekend.   I hear his lawn seriously 
needed cutting. :-)

ttfn

John

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Stephen Kuhn
On Tue, 2003-07-15 at 08:44, aron smith wrote:
 On Mon, 2003-07-14 at 15:02, Stephen Kuhn wrote:
  On Tue, 2003-07-15 at 07:42, JoeHill wrote:
   On 15 Jul 2003 07:10:32 +1000
   Stephen Kuhn [EMAIL PROTECTED] uttered:
   
sucked into MySQL
   
   ouch! should you have your sql checked for blockages after?
  
  Hell, a purge dunt hurt no one!
 It's up yehaa

The list might be up, but what happened to all the mail from Friday till
now? Did it get voided?

-- 
Tue Jul 15 10:05:01 EST 2003
 10:05:01 up 1 day,  2:08,  2 users,  load average: 0.40, 0.36, 0.28
-
|____  |kuhn media australia|
|   /-oo /| |'-.   |http://kma.0catch.com   |
|  .\__/ || |   |  ||
|   _ /  `._ \|_|_.-'  |stephen kuhn|
|  | /  \__.`=._) (_   | email: [EMAIL PROTECTED] |
-
  linux user #:267497 linux machine #:194239 * MDK 9.1+  RH 9  
  Mandrake Linux Kernel 2.4.21-11mdk Cooker for i586
-
 * This message was composed on a 100% Microsoft free computer *

Just out of curiosity does this actually mean something or have some
 of the few remaining bits of your brain just evaporated?
-- Patricia O Tuama, [EMAIL PROTECTED]

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Stephen Kuhn
On Tue, 2003-07-15 at 10:00, John Wilson wrote:

 Klyix will do nicely.
(For those living in Australia, the June edition of APC had Kylix3 for free included)

 And don't mind Stephen..he's just ranting because he had to find something 
 else to do than read the list this weekend.   I hear his lawn seriously 
 needed cutting. :-)

It's winter. Lawn dunna need a'cuttin!! (g)
...but you're right, I did have to finish something I kept putting
off...(my biz website)

...am I that predictable?

-- 
Tue Jul 15 10:15:00 EST 2003
 10:15:00 up 1 day,  2:18,  2 users,  load average: 0.18, 0.29, 0.26
-
|____  |kuhn media australia|
|   /-oo /| |'-.   |http://kma.0catch.com   |
|  .\__/ || |   |  ||
|   _ /  `._ \|_|_.-'  |stephen kuhn|
|  | /  \__.`=._) (_   | email: [EMAIL PROTECTED] |
-
  linux user #:267497 linux machine #:194239 * MDK 9.1+  RH 9  
  Mandrake Linux Kernel 2.4.21-11mdk Cooker for i586
-
 * This message was composed on a 100% Microsoft free computer *

Expedience is the best teacher.

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Carroll Grigsby
On Monday 14 July 2003 08:07 pm, Stephen Kuhn wrote:

 snip

 The list might be up, but what happened to all the mail from Friday till
 now? Did it get voided?

Stephen:
How do you answer mail that never got posted?
-- cmg


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com


Re: [newbie] DbaseIV database to use in Mandrake 9.1

2003-07-14 Thread Stephen Kuhn
On Tue, 2003-07-15 at 11:21, Carroll Grigsby wrote:
 On Monday 14 July 2003 08:07 pm, Stephen Kuhn wrote:
 
  snip
 
  The list might be up, but what happened to all the mail from Friday till
  now? Did it get voided?
 
 Stephen:
 How do you answer mail that never got posted?
 -- cmg

I have ESP

(Extra Sauce and Pickles)

-- 
Tue Jul 15 11:55:00 EST 2003
 11:55:00 up 1 day,  3:58,  2 users,  load average: 0.46, 0.15, 0.17
-
|____  |kuhn media australia|
|   /-oo /| |'-.   |http://kma.0catch.com   |
|  .\__/ || |   |  ||
|   _ /  `._ \|_|_.-'  |stephen kuhn|
|  | /  \__.`=._) (_   | email: [EMAIL PROTECTED] |
-
  linux user #:267497 linux machine #:194239 * MDK 9.1+  RH 9  
  Mandrake Linux Kernel 2.4.21-11mdk Cooker for i586
-
 * This message was composed on a 100% Microsoft free computer *

In the fetid fleapit of Rincewind's brain the projectionist of memory put
on reel two. Recollection began to flicker.
(The Last Continent)

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com