1DBI::PurePerl(3) User Contributed Perl Documentation DBI::PurePerl(3)
2
3
4
6 DBI::PurePerl -- a DBI emulation using pure perl (no C/XS compilation
7 required)
8
10 BEGIN { $ENV{DBI_PUREPERL} = 2 }
11 use DBI;
12
14 This is a pure perl emulation of the DBI internals. In almost all
15 cases you will be better off using standard DBI since the portions of
16 the standard version written in C make it *much* faster.
17
18 However, if you are in a situation where it isn't possible to install a
19 compiled version of standard DBI, and you're using pure-perl DBD driv‐
20 ers, then this module allows you to use most common features of DBI
21 without needing any changes in your scripts.
22
24 DBI::PurePerl is new so please treat it as experimental pending more
25 extensive testing. So far it has passed all tests with DBD::CSV,
26 DBD::AnyData, DBD::XBase, DBD::Sprite, DBD::mysqlPP. Please send bug
27 reports to Jeff Zucker at <jeff@vpservices.com> with a cc to
28 <dbi-dev@perl.org>.
29
31 The usage is the same as for standard DBI with the exception that you
32 need to set the enviornment variable DBI_PUREPERL if you want to use
33 the PurePerl version.
34
35 DBI_PUREPERL == 0 (the default) Always use compiled DBI, die
36 if it isn't properly compiled & installed
37
38 DBI_PUREPERL == 1 Use compiled DBI if it is properly compiled
39 & installed, otherwise use PurePerl
40
41 DBI_PUREPERL == 2 Always use PurePerl
42
43 You may set the enviornment variable in your shell (e.g. with set or
44 setenv or export, etc) or else set it in your script like this:
45
46 BEGIN { $ENV{DBI_PUREPERL}=2 }
47
48 before you "use DBI;".
49
51 In most situations simply install DBI (see the DBI pod for details).
52
53 In the situation in which you can not install DBI itself, you may manu‐
54 ally copy DBI.pm and PurePerl.pm into the appropriate directories.
55
56 For example:
57
58 cp DBI.pm /usr/jdoe/mylibs/.
59 cp PurePerl.pm /usr/jdoe/mylibs/DBI/.
60
61 Then add this to the top of scripts:
62
63 BEGIN {
64 $ENV{DBI_PUREPERL} = 1; # or =2
65 unshift @INC, '/usr/jdoe/mylibs';
66 }
67
68 (Or should we perhaps patch Makefile.PL so that if DBI_PUREPERL is set
69 to 2 prior to make, the normal compile process is skipped and the files
70 are installed automatically?)
71
73 Attributes
74
75 Boolean attributes still return boolean values but the actual values
76 used may be different, i.e., 0 or undef instead of an empty string.
77
78 Some handle attributes are either not supported or have very limited
79 functionality:
80
81 ActiveKids
82 InactiveDestroy
83 Kids
84 Taint
85 TaintIn
86 TaintOut
87
88 (and probably others)
89
90 Tracing
91
92 Trace functionality is more limited and the code to handle tracing is
93 only embeded into DBI:PurePerl if the DBI_TRACE environment variable is
94 defined. To enable total tracing you can set the DBI_TRACE environment
95 variable as usual. But to enable individual handle tracing using the
96 trace() method you also need to set the DBI_TRACE environment variable,
97 but set it to 0.
98
99 Parameter Usage Checking
100
101 The DBI does some basic parameter count checking on method calls.
102 DBI::PurePerl doesn't.
103
104 Speed
105
106 DBI::PurePerl is slower. Although, with some drivers in some contexts
107 this may not be very significant for you.
108
109 By way of example... the test.pl script in the DBI source distribution
110 has a simple benchmark that just does:
111
112 my $null_dbh = DBI->connect('dbi:NullP:','','');
113 my $i = 10_000;
114 $null_dbh->prepare('') while $i--;
115
116 In other words just prepares a statement, creating and destroying a
117 statement handle, over and over again. Using the real DBI this runs at
118 ~4550 handles per second whereas DBI::PurePerl manages ~2800 per second
119 on the same machine (not too bad really).
120
121 May not fully support hash()
122
123 If you want to use type 1 hash, i.e., "hash($string,1)" with
124 DBI::PurePerl, you'll need version 1.56 or higher of Math::BigInt
125 (available on CPAN).
126
127 Doesn't support preparse()
128
129 The DBI->preparse() method isn't supported in DBI::PurePerl.
130
131 Doesn't support DBD::Proxy
132
133 There's a subtle problem somewhere I've not been able to identify.
134 DBI::ProxyServer seem to work fine with DBI::PurePerl but DBD::Proxy
135 does not work 100% (which is sad because that would be far more useful
136 :) Try re-enabling t/80proxy.t for DBI::PurePerl to see if the problem
137 that remains will affect you're usage.
138
139 Others
140
141 can() - doesn't have any special behaviour
142
143 Please let us know if you find any other differences between DBI and
144 DBI::PurePerl.
145
147 Tim Bunce and Jeff Zucker.
148
149 Tim provided the direction and basis for the code. The original idea
150 for the module and most of the brute force porting from C to Perl was
151 by Jeff. Tim then reworked some core parts to boost the performance and
152 accuracy of the emulation. Thanks also to Randal Schwartz and John
153 Tobey for patches.
154
156 Copyright (c) 2002 Tim Bunce Ireland.
157
158 See COPYRIGHT section in DBI.pm for usage and distribution rights.
159
160
161
162perl v5.8.8 2006-02-07 DBI::PurePerl(3)