sqlite3 update hook function from golang

272 views
Skip to first unread message

Adusumilli SeshaChandra

unread,
Mar 3, 2015, 12:58:50 AM3/3/15
to golan...@googlegroups.com
i'm using "code.google.com/p/go-sqlite/go1/sqlite3" package for the call back function to get called, should the update or delete operations be executed from connection itself in golang or can they be executed from sqlite3 terminal so that i can keep program waiting for function to be called. callback function means i meant the UpdateFunc(). it is getting called fine when i used conn.execute(update stmt) on db. but when i went to terminal and executed the same update statement on db table it is not getting called. i'm keeping the connection open and making the program wait using waitgroup.

Maxim Khitrov

unread,
Mar 3, 2015, 7:53:57 AM3/3/15
to Adusumilli SeshaChandra, golang-nuts
The sqlite callback functions are not going to be called across
different connections. Also, you should be using the github version of
my package, though I have no idea if it still works with the current
cgo/GC combination. I know that it crashes with a more recent version
of sqlite amalgamation, but I haven't had the time to figure out why.

Adusumilli SeshaChandra

unread,
Mar 3, 2015, 7:59:27 AM3/3/15
to golan...@googlegroups.com, adusumilli....@vembu.com
is there any method for golang to get notified if a change occours in sqlite db??

Maxim Khitrov

unread,
Mar 3, 2015, 8:07:14 AM3/3/15
to Adusumilli SeshaChandra, golang-nuts
Look into the fsnotify package and just monitor the database file for
changes. You will not know what the change is and you may get a lot of
false positives just for lock/unlock operations.

On Tue, Mar 3, 2015 at 7:59 AM, Adusumilli SeshaChandra
<adusumilli....@vembu.com> wrote:
> is there any method for golang to get notified if a change occours in sqlite
> db??
>
> On Tuesday, March 3, 2015 at 6:23:57 PM UTC+5:30, Maxim Khitrov wrote:
>>
>> On Tue, Mar 3, 2015 at 12:58 AM, Adusumilli SeshaChandra
>> <adusumilli....@vembu.com> wrote:
>> > i'm using "code.google.com/p/go-sqlite/go1/sqlite3" package for the call
>> > back function to get called, should the update or delete operations be
>> > executed from connection itself in golang or can they be executed from
>> > sqlite3 terminal so that i can keep program waiting for function to be
>> > called. callback function means i meant the UpdateFunc(). it is getting
>> > called fine when i used conn.execute(update stmt) on db. but when i went
>> > to
>> > terminal and executed the same update statement on db table it is not
>> > getting called. i'm keeping the connection open and making the program
>> > wait
>> > using waitgroup.
>>
>> The sqlite callback functions are not going to be called across
>> different connections. Also, you should be using the github version of
>> my package, though I have no idea if it still works with the current
>> cgo/GC combination. I know that it crashes with a more recent version
>> of sqlite amalgamation, but I haven't had the time to figure out why.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages