Skip to content

Commit

Permalink
Added table_info and type_info; require DBI 1.0; fix capitalization a…
Browse files Browse the repository at this point in the history
…nd primary key person issue; fix dBase IV corruption.
  • Loading branch information
adelton committed Dec 7, 1998
1 parent ff7753e commit 894e334
Show file tree
Hide file tree
Showing 20 changed files with 392 additions and 245 deletions.
11 changes: 11 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

Revision history for Perl extension XBase and DBD::Xbase.

0.100
DBD::XBase: capitalized AND/OR in SQL commands now work,
method rows implemented, reported by cybertoast.
Updated to use _set_fbav.

XBase::SQL: fixed the primary key/key parsing problem, patch
by Bill Brinkley & Joe Johnston.

XBase::Memo: appending record to dBaseIV memo used to corrupt
the data -- reported by Dan Albertsson.

0.0696 Mon Oct 26 11:57:01 MET 1998

DBD::XBase: added bug reporting by INSERT command and fixed
Expand Down
32 changes: 15 additions & 17 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@

eval 'use XBase';
if (not $@)
{
if (eval { $XBase::VERSION < 0.063 } )
{
print <<EOF;
I can see you had the XBase module installed before. We have
a small support for ndx indexes now -- you might want to check
eg/use_index file to see how to use them or how to help to
make it work really well in the future.
EOF
}
}

eval 'use DBI';
if ($@ ne '')
{
if ($@ ne '') {
print <<EOF;
You do not seem to have DBI installed, so you will not be able
to use DBD::XBase (but XBase should still be running fine).
EOF
}
elsif ( eval ' $DBI::VERSION < 1.0 ' ) {
print <<EOF;
You have the DBI module, but it's the old version. Upgrade to
at least 1.0 to use this DBD::XBase. Or, use the DBD::XBase
version < 0.09, from your favorite CPAN mirror.
EOF
}

print <<EOF;
If there are some problems with this module, read the README first.
EOF

use ExtUtils::MakeMaker;
WriteMakefile(
Expand All @@ -29,7 +27,7 @@ WriteMakefile(
'VERSION_FROM' => 'lib/XBase.pm',
($] >= 5.005 ? (
'AUTHOR' => 'Jan Pazdziora (adelton@fi.muni.cz)',
'ABSTRACT' => 'Works with XBase (dbf) files, includes DBI support',
'ABSTRACT' => 'Reads and writes XBase (dbf) files, includes DBI support',
) : ()),
'PL_FILES' => { 'bin/dbfdump.PL' => 'bin/dbfdump' },
'EXE_FILES' => [ 'bin/dbfdump' ],
Expand Down
76 changes: 53 additions & 23 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,47 @@
XBase and DBD::XBase
------------------------------------

This is the README file for the XBase and DBD::XBase packages.
This is the README file for the XBase and DBD::XBase packages. Please
read it if you install this module for the first time or if there are
some problems with the module.

Module XBase provides access to XBase (dBase, Fox*) database files,
namely dbf, dbt, fpt, ndx, ntx. It provides native Perl interface
($table->get_record) to read and write the tables.

Module DBD::XBase is DBI driver that uses XBase to actually access the
data, giving you SQL interface ($dbh->prepare("SELECT * FROM TABLE")).
To use DBD::XBase, you need the DBI module -- please check the DBI(3)
man page for how to use it. As an argument to connect, give
"dbi:XBase:$dir", where $dir is directory with the data files.
namely dbf, dbt, fpt, ndx and ntx. It provides native Perl interface
($table->get_record, $table->update_record) to read and write the tables.
Module DBD::XBase is a DBI driver that uses the XBase module to work with
the data, providing you with DBI compliant processing interface and SQL
commands ($dbh->prepare("SELECT * FROM TABLE")). As an argument to
DBI->connect, specify "dbi:XBase:$dir", where $dir is the directory with
the data files.

So this package offers two ways of accessing your beloved data in dbf
files: XBase and DBD::XBase. You are free to pick any you find more
suitable for your project, I personally prefer the DBD::XBase.

You have to have Perl version 5.004. [Please do not ask me to make these
modules work under 5.003 or older version -- upgrade instead.]

You need a DBI module version at least 1.0 to use the DBD driver. If you
have older DBI and cannot upgrade for some reason, check the CPAN for
DBD::XBase version < 0.090. Those are the last versions that do not
require DBI 1.0. [Please do not ask me to make this line of DBD::XBase
work under older DBI's -- it will not work. Please do not ask me to make
the DBD::XBase work without DBI -- it will not work. Use the XBase
interface or install the DBI module.]

No other servers/software are needed, these modules directly read and
write the files. The main goal was to create a parser, mainly to work
with data from your current applications. If you are looking for
something more powerfull, check (for example) MySQL or PostgreSQL.
with data from your legacy applications. If you are looking for something
more powerfull, check (for example) MySQL or PostgreSQL.

The distribution also includes a dbfdump script that prints out the
content of the table in readable form.
The distribution also includes a dbfdump script that prints the content
of the table in readable form.

The support for ndx/ntx index files is rather minimal. It currently
allows you to search directly to the record you want. But you cannot
create the index, nor is the index updated when you change the dbf.
allows you to search directly to the record you want, in the XBase
module. But you cannot create the index, nor is the index updated when
you change the dbf. Check the eg/ directory for how you can help to
make it better.

This module is provided in a hope you might find it usefull. My intent
is to support as many variations of formats as possible, but I do not
Expand All @@ -34,7 +52,8 @@ data files if you feel your native XBase engines produce data
incompatible with this module.

Man pages for XBase, DBD::XBase and dbfdump are included, examples of
little scripts can also be found in eg directory of the distribution.
little scripts can also be found in eg/ directory of the distribution.
Read the DBI man page for DBI specific issues.

Installation:
Download the tar.gz, unpack it, change to the DBD-XBase-*
Expand All @@ -50,8 +69,8 @@ Installation:
perl -MCPAN -e shell
cpan> install XBase

You have to have Perl version 5.004. You need a DBI module to
use the DBD driver.
You have to have Perl version 5.004. You need a DBI module version
1.0 or higher to use the DBD driver.

Some people asked whether it is possible to use the module
even if they do not have root access. Even if this is in
Expand All @@ -69,20 +88,31 @@ Installation:
use lib '/your/directory';
use XBase;

Some people asked how to use this module when they are not
able to run make on their system. Even if it's beyond my
understanding why somebody would want to do such thing, you
are free to just copy the lib/ directory where you want it to
have. This should work.

Problems and bug reports:
If anything goes wrong when installing, please send me output
of your installation messages and of make test TEST_VERBOSE=1.

If there are errors when actually using the module on your
data, please send me example of your script, the errstr
data, please chcek first that it's really a XBase/DBD::XBase
problem. If so, please send me example of your script, the errstr
messages you get and (if possible) your data files that cause
the problems, so that I can trace down the problem. Add info
about your OS, version of Perl and other modules that might be
relevant. You can of course also send patches to actual bugs.
Please mention word XBase in the Subject line.

Sending bug reports and patches to c.l.p.m is fine but send
a copy to me as well, since I might miss your post.

Mention the word "XBase" in the Subject line, otherwise you
mail will probably just slip through my 4 MB mailbox without
being even read.

For general Perl issues, use the comp.lang.perl.m* newsgroups,
for DBI issues, use dbi-users@fugue.com.

If it works for you:
I'd appreciate any message if you use the module and find it
usefull -- I'm just curious for what tasks people use the
Expand Down
7 changes: 4 additions & 3 deletions bin/dbfdump.PL
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use Getopt::Long;
my %options;
Getopt::Long::GetOptions( \%options,
'help', 'version', 'info', 'rs=s', 'fs=s', 'undef=s', 'fields=s',
'nomemo', 'memofile=s',
'nomemo', 'memofile=s', 'memosep=s',
) or exit;
if (defined $options{'version'})
{ print "This is dbfdump version $XBase::VERSION\n"; exit; }
{ print "This is dbfdump version $XBase::VERSION.\n"; exit; }
if (@ARGV == 0 or defined $options{'help'})
{
Expand All @@ -35,7 +35,8 @@ Usage: dbfdump [ options ] files
--fs field separator
--fields comma separated list of fields to print
--undef what to print for NULL values
--memofile sepcifies unstandard name of attached memo file
--memofile specifies unstandard name of attached memo file
--memosep separator for dBase III dbt's -- default "\x1a\x1a"
all having as parameter a string; and also
--nomemo do not try to read the memo (dbt/fpt) file
--info print info about the file and fields
Expand Down
7 changes: 3 additions & 4 deletions dbit/00base.t
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ foreach $file ("lib.pl", "t/lib.pl") {
last;
}
}
if ($verbose) { print "Driver is $mdriver\n"; }

# Base DBD Driver Test

Expand All @@ -34,16 +33,16 @@ print "ok 2\n";
$switch = DBI->internal;
(ref $switch eq 'DBI::dr') ? print "ok 3\n" : print "not ok 3\n";



# This is a special case. install_driver should not normally be used.
$drh = DBI->install_driver($mdriver);

(ref $drh eq 'DBI::dr') ? print "ok 4\n" : print "not ok 4\n";

if ($drh->{Version}) {
print "ok 5\n";
if ($verbose) {
print "Driver version is ", $drh->{Version}, "\n";
}
print "Driver version is ", $drh->{Version}, "\n";
}

BEGIN { $tests = 5 }
Expand Down
26 changes: 22 additions & 4 deletions dbit/10dsnlist.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
#
require DBI;
$mdriver = "";
foreach $file ("lib.pl", "t/lib.pl") {
foreach $file ("lib.pl", "t/lib.pl", "DBD-~DBD_DRIVER~/t/lib.pl") {
do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
exit 10;
}
if ($mdriver ne '') {
last;
}
}
if ($mdriver eq 'pNET' || $mdriver eq 'ODBC') {
if ($mdriver eq 'pNET' || $mdriver eq 'Adabas') {
print "1..0\n";
exit 0;
}
if ($verbose) { print "Driver is $mdriver\n"; }
print "Driver is $mdriver\n";

sub ServerError() {
print STDERR ("Cannot connect: ", $DBI::errstr, "\n",
Expand All @@ -47,7 +47,7 @@ while (Testing()) {
or ServerError();

Test($state or defined(@dsn = DBI->data_sources($mdriver)));
if (!$state && $verbose) {
if (!$state) {
my $d;
print "List of $mdriver data sources:\n";
foreach $d (@dsn) {
Expand All @@ -56,6 +56,24 @@ while (Testing()) {
print "List ends.\n";
}
Test($state or $dbh->disconnect());

#
# Try different DSN's
#
my(@dsnList);
if (($mdriver eq 'mysql' or $mdriver eq 'mSQL')
and $test_dsn eq "DBI:$mdriver:test") {
@dsnList = ("DBI:$mdriver:test:localhost",
"DBI:$mdriver:test;localhost",
"DBI:$mdriver:database=test;host=localhost");
}
my($dsn);
foreach $dsn (@dsnList) {
Test($state or ($dbh = DBI->connect($dsn, $test_user,
$test_password)))
or print "Cannot connect to DSN $dsn: ${DBI::errstr}\n";
Test($state or $dbh->disconnect());
}
}

exit 0;
Expand Down
14 changes: 9 additions & 5 deletions dbit/20createdrop.t
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ while (Testing()) {
# Create a new table
#
my $def;
Test($state or ($def = TableDefinition($table,
["id", "INTEGER", 4, 0],
["name", "CHAR", 64, 0]),
$dbh->do($def)))
or DbiError($dbh->err, $dbh->errstr);
if (!$state) {
($def = TableDefinition($table,
["id", "INTEGER", 4, 0],
["name", "CHAR", 64, 0]));
print "Creating table:\n$def\n";
}
Test($state or $dbh->do($def))
or DbiError($dbh->err, $dbh->errstr);


#
# ... and drop it.
Expand Down
Loading

0 comments on commit 894e334

Please sign in to comment.