how do I set PRAGMA?

151 views
Skip to first unread message

bornmw

unread,
Dec 2, 2009, 7:15:17 AM12/2/09
to Xerial
Hi,

I started to use SQLite recently, and one of the reasons for that was
that starting with 3.6.18 SQLite supports recursive triggers.
To enable recursive triggers a PRAGMA statement must be executed:
PRAGMA recursive_triggers = boolean;

It is possible to issue this PRAGMA statement prior to the actual
statement execution, but it's clearly not a very good approach.
Question: is there any more elegant way of doing that with Xerial
driver?

Thanks,
Oleg

Taro L. Saito

unread,
Dec 2, 2009, 7:25:43 AM12/2/09
to xerial
How about the following approach to enable recursive_trigger feature?

Properties prop = new Properties();
prop.setProperty("recursive_triggers", "true");
Connection conn = DriverManager.getConnection("jdbc:sqlite:", prop);

Although the above code is not supported in the current sqlite-jdbc-3.6.19,
adding such an feature is an easy task, and can be included in the next release
for sqlite-jdbc-3.6.20.

--
Taro L. Saito
<l...@xerial.org>
University of Tokyo
http://www.xerial.org/leo
Tel. +81-47-136-3985 (63985)
> --
>
> You received this message because you are subscribed to the Google Groups "Xerial" group.
> To post to this group, send email to xer...@googlegroups.com.
> To unsubscribe from this group, send email to xerial+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xerial?hl=en.
>
>
>

MAILER-DAEMON

unread,
Dec 3, 2009, 3:54:32 AM12/3/09
to Xerial
I second that.

And I would like to see foreign_keys here as well, since that was one
of the reasons *I* am using SQLite.

Thinking about it, why not make all pragmas supported by SQLite into a
property value? (If it is not an unreasonable amount of extra work, of
course).

Best regards,
Thomas

On Dec 2, 1:25 pm, "Taro L. Saito" <l...@xerial.org> wrote:
> How about the following approach to enable recursive_trigger feature?
>
>  Properties prop = new Properties();
>  prop.setProperty("recursive_triggers", "true");
>  Connection conn = DriverManager.getConnection("jdbc:sqlite:", prop);
>
> Although the above code is not supported in the current sqlite-jdbc-3.6.19,
> adding such an feature is an easy task, and can be included in the next release
>  for sqlite-jdbc-3.6.20.
>
> --
> Taro L. Saito
> <l...@xerial.org>
> University of Tokyohttp://www.xerial.org/leo
> Tel. +81-47-136-3985 (63985)

Taro L. Saito

unread,
Dec 3, 2009, 4:11:54 AM12/3/09
to xerial
Great,

I think Tohmas's idea would be very useful.

Here is the list of pragmas.
http://www.sqlite.org/pragma.html

Let me consider how to set these features upon establishing the connections.

Thanks,
--
Taro L. Saito
<l...@xerial.org>
University of Tokyo
http://www.xerial.org/leo
Tel. +81-47-136-3985 (63985)




MAILER-DAEMON

unread,
Dec 3, 2009, 4:21:55 AM12/3/09
to Xerial
And on a secound thought, I would also like to see support for the
flags parameter of sqlite3_open_v2 (http://sqlite.org/c3ref/
open.html).

This is not even possible with PRAGMA.

For instance, I have an application where SQLITE_OPEN_READONLY (The
database is opened in read-only mode. If the database does not already
exist, an error is returned.) would be useful.

Regards,
Thomas

On Dec 3, 10:11 am, "Taro L. Saito" <l...@xerial.org> wrote:
> Great,
>
> I think Tohmas's idea would be very useful.
>
> Here is the list of pragmas.http://www.sqlite.org/pragma.html
>
> Let me consider how to set these features upon establishing the connections.
>
> Thanks,
> --
> Taro L. Saito
> <l...@xerial.org>
> University of Tokyohttp://www.xerial.org/leo
> Tel. +81-47-136-3985 (63985)
>

Taro L. Saito

unread,
Dec 3, 2009, 6:46:28 AM12/3/09
to xerial
I am considering the same thing, using sqlite3_open_v2 API, and
it's been on my task list:
http://code.google.com/p/xerial/issues/detail?id=19



--
Taro L. Saito
<l...@xerial.org>
University of Tokyo
http://www.xerial.org/leo
Tel. +81-47-136-3985 (63985)




Taro L. Saito

unread,
Dec 8, 2009, 6:17:36 AM12/8/09
to Xerial
Today, I implemented these features discussed in this thread,
including read-only mode, foreign key, recursive triggers, etc.

These updates will be available soon in the next release, sqlite-
jdbc-3.6.20.


> I am considering the same thing, using sqlite3_open_v2 API, and
> it's been on my task list:http://code.google.com/p/xerial/issues/detail?id=19
>
> --
> Taro L. Saito
> <l...@xerial.org>

bornmw

unread,
Dec 20, 2009, 9:41:22 AM12/20/09
to Xerial

Taro L. Saito

unread,
Dec 24, 2009, 8:53:19 PM12/24/09
to Xerial

Thanks for the good article!

One of the reasons I maintain this sqlite-jdbc driver is its
portability:
ease of installation, simply file copy can transport databases and
generated database can be used in various programming languages other
than Java.

The sqlite-jdbc is also useful to teach students how DBMS works.

Reply all
Reply to author
Forward
0 new messages