1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

- Accept empty filename at connect (sqlite will open a tempfile) (DAMI)

- Documented the connect() method (DAMI)
This commit is contained in:
Laurent Dami 2009-07-23 07:00:26 +00:00
parent baebd1593e
commit 3997c0ffaf
3 changed files with 48 additions and 3 deletions

View file

@ -15,6 +15,8 @@ Changes for Perl extension DBD-SQLite
- Added a default implementation for the REGEXP infix operator (DAMI) - Added a default implementation for the REGEXP infix operator (DAMI)
- Renamed several internal sqlite3_ functions to sqlite_ - Renamed several internal sqlite3_ functions to sqlite_
for clarity (ISHIGAKI) for clarity (ISHIGAKI)
- Accept empty filename at connect (sqlite will open a tempfile) (DAMI)
- Documented the connect() method (DAMI)
1.26_02 Fri 19 Jun 2009 1.26_02 Fri 19 Jun 2009
- Updated to SQLite 3.6.15 (DUNCAND) - Updated to SQLite 3.6.15 (DUNCAND)

View file

@ -98,7 +98,7 @@ sub connect {
# To avoid unicode and long file name problems on Windows, # To avoid unicode and long file name problems on Windows,
# convert to the shortname if the file (or parent directory) exists. # convert to the shortname if the file (or parent directory) exists.
if ( $^O =~ /MSWin32/ and $real ne ':memory:' ) { if ( $^O =~ /MSWin32/ and $real ne ':memory:' and $real ne '') {
require Win32; require Win32;
require File::Basename; require File::Basename;
my ($file, $dir, $suffix) = File::Basename::fileparse($real); my ($file, $dir, $suffix) = File::Basename::fileparse($real);
@ -505,7 +505,7 @@ DBD::SQLite - Self-contained RDBMS in a DBI Driver
=head1 SYNOPSIS =head1 SYNOPSIS
use DBI; use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=dbfile","",""); my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","");
=head1 DESCRIPTION =head1 DESCRIPTION
@ -554,6 +554,29 @@ details about core features.
Currently many statement attributes are not implemented or are Currently many statement attributes are not implemented or are
limited by the typeless nature of the SQLite database. limited by the typeless nature of the SQLite database.
=head1 CONNECTING
The name of the database file is passed in the the DBI connection
string :
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","");
The file is opened in read/write mode, and will be created if
it does not exist yet.
If the filename C<$dbfile> is ":memory:", then a private, temporary
in-memory database is created for the connection. This in-memory
database will vanish when the database connection is closed. Future
versions of SQLite might make use of additional special filenames that
begin with the ":" character. It is recommended that when a database
filename actually does begin with a ":" character you should prefix
the filename with a pathname such as "./" to avoid ambiguity.
If the filename C<$dbfile> is an empty string, then a private,
temporary on-disk database will be created. This private database will
be automatically deleted as soon as the database connection is closed.
=head1 DRIVER PRIVATE ATTRIBUTES =head1 DRIVER PRIVATE ATTRIBUTES
=head2 Database Handle Attributes =head2 Database Handle Attributes
@ -1290,6 +1313,11 @@ code we work with leaks.
Reading/writing into blobs using C<sqlite2_blob_open> / C<sqlite2_blob_close>. Reading/writing into blobs using C<sqlite2_blob_open> / C<sqlite2_blob_close>.
=head2 Flags for sqlite3_open_v2
Support the full API of sqlite3_open_v2 (flags for opening the file).
=head1 SUPPORT =head1 SUPPORT
Bugs should be reported via the CPAN bug tracker at Bugs should be reported via the CPAN bug tracker at

View file

@ -13,7 +13,7 @@ use t::lib::Test;
use Test::More; use Test::More;
BEGIN { BEGIN {
if ( $] >= 5.008005 ) { if ( $] >= 5.008005 ) {
plan( tests => (($^O eq 'cygwin') ? 13 : 25) ); plan( tests => (($^O eq 'cygwin') ? 15 : 27) );
} else { } else {
plan( skip_all => 'Unicode is not supported before 5.8.5' ); plan( skip_all => 'Unicode is not supported before 5.8.5' );
} }
@ -75,6 +75,21 @@ foreach my $subdir ( 'longascii', 'adatb
unlink(_path($dbfilex)) if -e _path($dbfilex); unlink(_path($dbfilex)) if -e _path($dbfilex);
} }
# connect to an empty filename - sqlite will create a tempfile
eval {
my $dbh = DBI->connect("dbi:SQLite:dbname=", undef, undef, {
RaiseError => 1,
PrintError => 0,
} );
isa_ok( $dbh, 'DBI::db' );
};
is( $@, '', "Could connect to temp database (empty filename)" );
diag( $@ ) if $@;
sub _path { # copied from DBD::SQLite::connect sub _path { # copied from DBD::SQLite::connect
my $path = shift; my $path = shift;