Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 87297
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: jacobs [...] koiru.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: URI filenames in DBD::SQLite
Date: Thu, 25 Jul 2013 14:12:48 +0200
To: bug-DBD-SQLite [...] rt.cpan.org
From: Jan Dusek <jacobs [...] koiru.com>
Hello, Could DBD::SQLite be enhanced so that URI filename capability can be enabled during runtime? I'm working with in-memory databases in SQLite and I need to use a query string in the connection URI (e.g. 'dbi:SQLite:dbname=file:memdb?mode=memory&cache=shared'). However at the moment I don't think there's a good way to do this via DBD::SQLite due to the URI filename capability being disabled by default (see: http://www.sqlite.org/uri.html chapter 2.0 Backwards Compatibility). The only way I found this could be done is to recompile the SQLite using SQLITE_USE_URI compile-time option, but this is not a very portable approach. Enabling this during runtime should be achievable by using either of the following C functions (quoting from http://www.sqlite.org/uri.html): * The sqlite3_config (SQLITE_CONFIG_URI, 1); configuration option is set at application start-time. * The SQLITE_OPEN_URI bit is OR-ed in with the set bits passed in as the 3rd parameter to the sqlite3_open_v2() interface. Thanks for your time, --Jan
Hi. Implemented in a branch with two tests. https://github.com/DBD-SQLite/DBD-SQLite/tree/uri_filename On Thu Jul 25 21:13:10 2013, jacobs@koiru.com wrote: Show quoted text
> Hello, > > Could DBD::SQLite be enhanced so that URI filename capability can be > enabled during runtime? > > I'm working with in-memory databases in SQLite and I need to use a > query string in the connection URI (e.g. > 'dbi:SQLite:dbname=file:memdb?mode=memory&cache=shared'). > > However at the moment I don't think there's a good way to do this via > DBD::SQLite due to the URI filename capability being disabled by > default (see: http://www.sqlite.org/uri.html chapter 2.0 Backwards > Compatibility). The only way I found this could be done is to > recompile the SQLite using SQLITE_USE_URI compile-time option, but > this is not a very portable approach. > > Enabling this during runtime should be achievable by using either of > the following C functions (quoting from > http://www.sqlite.org/uri.html): > > * The sqlite3_config (SQLITE_CONFIG_URI, 1); configuration option is > set at application start-time. > * The SQLITE_OPEN_URI bit is OR-ed in with the set bits passed in as > the 3rd parameter to the sqlite3_open_v2() interface. > > Thanks for your time, > --Jan
Subject: Re: [rt.cpan.org #87297] URI filenames in DBD::SQLite
Date: Mon, 29 Jul 2013 16:17:42 +0200
To: bug-DBD-SQLite [...] rt.cpan.org
From: Jan Dusek <jacobs [...] koiru.com>
Thanks a lot for such fast response! However the upgrade seems to have broken something in the URI syntax: $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db?cache=shared", "", "", { RaiseError => 1 }) or die $DBI::errstr; DBI connect('dbname=file:/db.db?cache=shared','',...) failed: unable to open database file at ..//analytics.pm line 75. $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db", "", "", { RaiseError => 1 }) or die $DBI::errstr; DBI connect('dbname=file:/db.db','',...) failed: unable to open database file at ..//analytics.pm line 75. This has worked with the previous version. If I remove the 'file:', it gets better: $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db", "", "", { RaiseError => 1 }) or die $DBI::errstr; But then when I now try to open the database as shared, it fails accessing the content correctly (do I need to enable the URI processing somehow?): $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db?cache=shared", "", "", { RaiseError => 1 }) or die $DBI::errstr; DBD::SQLite::db prepare failed: no such table: events at ..//analytics.pm line 548. On Sunday, July 28, 2013 at 16:26 , Kenichi Ishigaki via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87297 > > > Hi. Implemented in a branch with two tests. > > https://github.com/DBD-SQLite/DBD-SQLite/tree/uri_filename > > On Thu Jul 25 21:13:10 2013, jacobs@koiru.com (mailto:jacobs@koiru.com) wrote:
> > Hello, > > > > Could DBD::SQLite be enhanced so that URI filename capability can be > > enabled during runtime? > > > > I'm working with in-memory databases in SQLite and I need to use a > > query string in the connection URI (e.g. > > 'dbi:SQLite:dbname=file:memdb?mode=memory&cache=shared'). > > > > However at the moment I don't think there's a good way to do this via > > DBD::SQLite due to the URI filename capability being disabled by > > default (see: http://www.sqlite.org/uri.html chapter 2.0 Backwards > > Compatibility). The only way I found this could be done is to > > recompile the SQLite using SQLITE_USE_URI compile-time option, but > > this is not a very portable approach. > > > > Enabling this during runtime should be achievable by using either of > > the following C functions (quoting from > > http://www.sqlite.org/uri.html): > > > > * The sqlite3_config (SQLITE_CONFIG_URI, 1); configuration option is > > set at application start-time. > > * The SQLITE_OPEN_URI bit is OR-ed in with the set bits passed in as > > the 3rd parameter to the sqlite3_open_v2() interface. > > > > Thanks for your time, > > --Jan
>
Subject: Re: [rt.cpan.org #87297] URI filenames in DBD::SQLite
Date: Mon, 29 Jul 2013 16:25:21 +0200
To: bug-DBD-SQLite [...] rt.cpan.org
From: Jan Dusek <jacobs [...] koiru.com>
I forgot to mention that the last example: $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db?cache=shared", "", "", { RaiseError => 1 }) or die $DBI::errstr; DBD::SQLite::db prepare failed: no such table: events at ..//analytics.pm line 548. creates the file: $ ls -l /db.db\?cache\=shared -rw-r--r-- 1 0 Jul 29 16:05 ../db.db?cache=shared Which would indeed point towards URI processing not being enabled here. I've tried enabling URI explicitly, but no joy: use DBD::SQLite; $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db?cache=shared", "", "", { RaiseError => 1, sqlite_open_flags => DBD::SQLite::SQLITE_OPEN_URI }) or die $DBI::errstr; Bareword "DBD::SQLite::SQLITE_OPEN_URI" not allowed while "strict subs" in use at ..//analytics.pm line 75. (The same with DBD::SQLite::OPEN_READONLY gets through syntax-wise.) On Monday, July 29, 2013 at 16:17 , Jan Dusek wrote: Show quoted text
> Thanks a lot for such fast response! > > However the upgrade seems to have broken something in the URI syntax: > > $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db?cache=shared", "", "", { RaiseError => 1 }) or die $DBI::errstr; > DBI connect('dbname=file:/db.db?cache=shared','',...) failed: unable to open database file at ..//analytics.pm line 75. > > $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db", "", "", { RaiseError => 1 }) or die $DBI::errstr; > DBI connect('dbname=file:/db.db','',...) failed: unable to open database file at ..//analytics.pm line 75. > > This has worked with the previous version. > > > If I remove the 'file:', it gets better: > > $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db", "", "", { RaiseError => 1 }) or die $DBI::errstr; > > But then when I now try to open the database as shared, it fails accessing the content correctly (do I need to enable the URI processing somehow?): > > $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db?cache=shared", "", "", { RaiseError => 1 }) or die $DBI::errstr; > DBD::SQLite::db prepare failed: no such table: events at ..//analytics.pm line 548. > > > > > On Sunday, July 28, 2013 at 16:26 , Kenichi Ishigaki via RT wrote:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=87297 > > > > > Hi. Implemented in a branch with two tests. > > > > https://github.com/DBD-SQLite/DBD-SQLite/tree/uri_filename > > > > On Thu Jul 25 21:13:10 2013, jacobs@koiru.com (mailto:jacobs@koiru.com) wrote:
> > > Hello, > > > > > > Could DBD::SQLite be enhanced so that URI filename capability can be > > > enabled during runtime? > > > > > > I'm working with in-memory databases in SQLite and I need to use a > > > query string in the connection URI (e.g. > > > 'dbi:SQLite:dbname=file:memdb?mode=memory&cache=shared'). > > > > > > However at the moment I don't think there's a good way to do this via > > > DBD::SQLite due to the URI filename capability being disabled by > > > default (see: http://www.sqlite.org/uri.html chapter 2.0 Backwards > > > Compatibility). The only way I found this could be done is to > > > recompile the SQLite using SQLITE_USE_URI compile-time option, but > > > this is not a very portable approach. > > > > > > Enabling this during runtime should be achievable by using either of > > > the following C functions (quoting from > > > http://www.sqlite.org/uri.html): > > > > > > * The sqlite3_config (SQLITE_CONFIG_URI, 1); configuration option is > > > set at application start-time. > > > * The SQLITE_OPEN_URI bit is OR-ed in with the set bits passed in as > > > the 3rd parameter to the sqlite3_open_v2() interface. > > > > > > Thanks for your time, > > > --Jan
> >
>
Try uri=file:path?mode=... ("uri" instead of "dbname") and/or set DBD::SQLite::OPEN_URI flag (via sqlite_open_flags attribute) as noted in the pod. To secure complete backward compatibility, dbname=file:... is not considered as a URI filename. See also t/56_open_flags.t and t/57_uri_filename.t for more complete examples. HTH On Mon Jul 29 23:18:03 2013, jacobs@koiru.com wrote: Show quoted text
> Thanks a lot for such fast response! > > However the upgrade seems to have broken something in the URI syntax: > > $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db?cache=shared", > "", "", { RaiseError => 1 }) or die $DBI::errstr; > DBI connect('dbname=file:/db.db?cache=shared','',...) failed: unable > to open database file at ..//analytics.pm line 75. > > $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db", "", "", { > RaiseError => 1 }) or die $DBI::errstr; > DBI connect('dbname=file:/db.db','',...) failed: unable to open > database file at ..//analytics.pm line 75. > > This has worked with the previous version. > > > If I remove the 'file:', it gets better: > > $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db", "", "", { RaiseError > => 1 }) or die $DBI::errstr; > > But then when I now try to open the database as shared, it fails > accessing the content correctly (do I need to enable the URI > processing somehow?): > > $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db?cache=shared", "", "", > { RaiseError => 1 }) or die $DBI::errstr; > DBD::SQLite::db prepare failed: no such table: events at > ..//analytics.pm line 548. > > > > > On Sunday, July 28, 2013 at 16:26 , Kenichi Ishigaki via RT wrote:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=87297 > > > > > Hi. Implemented in a branch with two tests. > > > > https://github.com/DBD-SQLite/DBD-SQLite/tree/uri_filename > > > > On Thu Jul 25 21:13:10 2013, jacobs@koiru.com > > (mailto:jacobs@koiru.com) wrote:
> > > Hello, > > > > > > Could DBD::SQLite be enhanced so that URI filename capability can > > > be > > > enabled during runtime? > > > > > > I'm working with in-memory databases in SQLite and I need to use a > > > query string in the connection URI (e.g. > > > 'dbi:SQLite:dbname=file:memdb?mode=memory&cache=shared'). > > > > > > However at the moment I don't think there's a good way to do this > > > via > > > DBD::SQLite due to the URI filename capability being disabled by > > > default (see: http://www.sqlite.org/uri.html chapter 2.0 Backwards > > > Compatibility). The only way I found this could be done is to > > > recompile the SQLite using SQLITE_USE_URI compile-time option, but > > > this is not a very portable approach. > > > > > > Enabling this during runtime should be achievable by using either > > > of > > > the following C functions (quoting from > > > http://www.sqlite.org/uri.html): > > > > > > * The sqlite3_config (SQLITE_CONFIG_URI, 1); configuration option > > > is > > > set at application start-time. > > > * The SQLITE_OPEN_URI bit is OR-ed in with the set bits passed in > > > as > > > the 3rd parameter to the sqlite3_open_v2() interface. > > > > > > Thanks for your time, > > > --Jan
> >
Subject: Re: [rt.cpan.org #87297] URI filenames in DBD::SQLite
Date: Mon, 29 Jul 2013 20:32:05 +0200
To: bug-DBD-SQLite [...] rt.cpan.org
From: Jan Dusek <jacobs [...] koiru.com>
Ah, thank you, with the "uri" it works perfectly. On Jul 29, 2013, at 17:25 , Kenichi Ishigaki via RT <bug-DBD-SQLite@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87297 > > > Try uri=file:path?mode=... ("uri" instead of "dbname") and/or set DBD::SQLite::OPEN_URI flag (via sqlite_open_flags attribute) as noted in the pod. To secure complete backward compatibility, dbname=file:... is not considered as a URI filename. See also t/56_open_flags.t and t/57_uri_filename.t for more complete examples. > > HTH > > > On Mon Jul 29 23:18:03 2013, jacobs@koiru.com wrote:
>> Thanks a lot for such fast response! >> >> However the upgrade seems to have broken something in the URI syntax: >> >> $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db?cache=shared", >> "", "", { RaiseError => 1 }) or die $DBI::errstr; >> DBI connect('dbname=file:/db.db?cache=shared','',...) failed: unable >> to open database file at ..//analytics.pm line 75. >> >> $g_dbh = DBI->connect("dbi:SQLite:dbname=file:/db.db", "", "", { >> RaiseError => 1 }) or die $DBI::errstr; >> DBI connect('dbname=file:/db.db','',...) failed: unable to open >> database file at ..//analytics.pm line 75. >> >> This has worked with the previous version. >> >> >> If I remove the 'file:', it gets better: >> >> $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db", "", "", { RaiseError >> => 1 }) or die $DBI::errstr; >> >> But then when I now try to open the database as shared, it fails >> accessing the content correctly (do I need to enable the URI >> processing somehow?): >> >> $g_dbh = DBI->connect("dbi:SQLite:dbname=/db.db?cache=shared", "", "", >> { RaiseError => 1 }) or die $DBI::errstr; >> DBD::SQLite::db prepare failed: no such table: events at >> ..//analytics.pm line 548. >> >> >> >> >> On Sunday, July 28, 2013 at 16:26 , Kenichi Ishigaki via RT wrote:
>>> <URL: https://rt.cpan.org/Ticket/Display.html?id=87297 > >>> >>> Hi. Implemented in a branch with two tests. >>> >>> https://github.com/DBD-SQLite/DBD-SQLite/tree/uri_filename >>> >>> On Thu Jul 25 21:13:10 2013, jacobs@koiru.com >>> (mailto:jacobs@koiru.com) wrote:
>>>> Hello, >>>> >>>> Could DBD::SQLite be enhanced so that URI filename capability can >>>> be >>>> enabled during runtime? >>>> >>>> I'm working with in-memory databases in SQLite and I need to use a >>>> query string in the connection URI (e.g. >>>> 'dbi:SQLite:dbname=file:memdb?mode=memory&cache=shared'). >>>> >>>> However at the moment I don't think there's a good way to do this >>>> via >>>> DBD::SQLite due to the URI filename capability being disabled by >>>> default (see: http://www.sqlite.org/uri.html chapter 2.0 Backwards >>>> Compatibility). The only way I found this could be done is to >>>> recompile the SQLite using SQLITE_USE_URI compile-time option, but >>>> this is not a very portable approach. >>>> >>>> Enabling this during runtime should be achievable by using either >>>> of >>>> the following C functions (quoting from >>>> http://www.sqlite.org/uri.html): >>>> >>>> * The sqlite3_config (SQLITE_CONFIG_URI, 1); configuration option >>>> is >>>> set at application start-time. >>>> * The SQLITE_OPEN_URI bit is OR-ed in with the set bits passed in >>>> as >>>> the 3rd parameter to the sqlite3_open_v2() interface. >>>> >>>> Thanks for your time, >>>> --Jan
>>>
> > >
Closed this ticket as DBD::SQLite 1.41_01 with URI support was released. Thanks.