Re: [sqlite] Using SQLite by Jay Kreibich (2010 paperback edition)

2013-12-30 Thread Navaneeth K N
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hello,

On 12/31/13 8:18 AM, Bob Cochran wrote:
> I'm working on a tough project that requires me to use Node.js and
> SQLite. I'm building a database with SQLite version 3.8.2.
> 
> My question is, would purchasing the book "Using Sqlite" by Jay Kreibich
> still be mostly pertinent to SQLite 3.8.x features? Would it be helpful
> in the context how Node.js is used? I realize that Mr. Kreibich was
> writing the book and bringing it to publication just as Node.js was
> being invented in 2009.
> 
> Does anyone know if this book will be updated?
> 
> Or is there a different book title I should look at?

- From my personal experience, you don't need a book to learn/use SQLite.
It is very well documented and pretty easy to get started. If you are in
doubt at anytime, get on the interactive SQLIte console and try out
commands directly on the database.

> 
> Right now, my major difficulties seem to be in my own grasp of
> asynchronous programming. It is my own deficient grasp of the logic
> problems that are biting me; I need to "get it" and understand Node
> style programming. An example is: I need to insert two rows to an SQLite
> table, but because I'm using non-blocking interface software to do the
> actual inserts, and I'm probably using that software incorrectly, only
> one insert is being done.

You need to do one insert, then in the success callback of the insert,
do the second insert.

If you use `node-sqlite3`[1], then it allows you to serialize the query
execution in which case it is simpler.

[1]: https://github.com/mapbox/node-sqlite3

> 
> Thanks
> 
> Bob Cochran
> Greenbelt, Maryland, USA
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

- -- 
Cheers,
Navaneeth
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org

iQEcBAEBCgAGBQJSwlUyAAoJEHFACYSL7h6kUCwH/0tMAKjgGldSPeXWKyMT3j8t
X8br4nLyyxsEUa0xASm6S7jiPrwQ8D1IKEjSu1cbX4AAimZSzeMXnIlwyuKVxF7Q
1NLNknzei/LKM1m+jwRYtC6Pencm4o2Jnrc5kcKBrXAh/M4w6r+7Z1dpBN7LK/wP
RZs42203DoV2V4/0FxoBP9OxgdP+AKSYRf4UrOqJM5XZiPVaoi9J43MqRyldwUaU
0n9cTlGzFqgKMxyQgq4cqoQKM9BztvAxkq5jU72FJHXg/3N6tJennL/ACrf2qkff
G5rSdb0SDOUAvajy8cybRj90F2e3E+3C6uvrph7UdD/86A4PitzKnezFw2y72L4=
=gKGL
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Using SQLite by Jay Kreibich (2010 paperback edition)

2013-12-30 Thread Bob Cochran
I'm working on a tough project that requires me to use Node.js and 
SQLite. I'm building a database with SQLite version 3.8.2.


My question is, would purchasing the book "Using Sqlite" by Jay Kreibich 
still be mostly pertinent to SQLite 3.8.x features? Would it be helpful 
in the context how Node.js is used? I realize that Mr. Kreibich was 
writing the book and bringing it to publication just as Node.js was 
being invented in 2009.


Does anyone know if this book will be updated?

Or is there a different book title I should look at?

Right now, my major difficulties seem to be in my own grasp of 
asynchronous programming. It is my own deficient grasp of the logic 
problems that are biting me; I need to "get it" and understand Node 
style programming. An example is: I need to insert two rows to an SQLite 
table, but because I'm using non-blocking interface software to do the 
actual inserts, and I'm probably using that software incorrectly, only 
one insert is being done.


Thanks

Bob Cochran
Greenbelt, Maryland, USA

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Web application with SQLite

2013-12-30 Thread Tim Johnson
  Understood. Thanks
* Mohd Radzi Ibrahim  [131229 13:54]:
> fossil is a webserver by itself with sqlite as the database engine. AFAIK,
> there's no scripting language used on the server. All written in C.
> 
> 
> 
> On Mon, Dec 30, 2013 at 1:02 AM, Tim Johnson  wrote:
> 
> > * Stephan Beal  [131229 07:48]:
> > > On Sun, Dec 29, 2013 at 5:35 PM, Tim Johnson  wrote:
> > >
> > > >   :) And if I request http://www.sqlite.org/src/timeline/index.php
> > > >   I get the same page, so Igor, Mr. Hipp uses PHP as the 'querying'
> > > >   code, or so I presume.
> > > >
> > >
> > > LOL! If you try /timeline/foo/bar/baz you'll get the same thing. That
> > page
> > > is written in C. The /timeline part of the request is intercepted by C
> > code
> > > and the rest is ignored.
> > >
> > > http://fossil-scm.org/index.html/timeline/foo/bar/baz
> >   I stand (embarrassingly) corrected 
> >
> >   FYI: I started out doing web programming in 1995 using C, but
> >   transitioned to scripting languages around 2001. I didn't know
> >   anyone was still doing web application in C!
> >
> >   It stands to reason in terms of performance, for sure.
> >
> >   Thanks
> > --
> > Tim
> > tim at tee jay forty nine dot com or akwebsoft dot com
> > http://www.akwebsoft.com, http://www.tj49.com
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Windows Embedded Handheld 6.5

2013-12-30 Thread Joe Mistachkin

Ryan Finnesey wrote:
> 
> If I want to add a SQLite database to an application I am developing to
run
> on Windows Embedded Handheld 6.5 do I need to compile the SQLite Source
Code
> or do I just use System.Data.SQLite
> 

Unless you need custom compilation options, it will probably be easier just
to
use the System.Data.SQLite binaries for "PocketPC", seen here under
"Precompiled Binaries for Windows CE (.NET Compact Framework)":

https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

--
Joe Mistachkin

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is that same between rebinding every parameter and

2013-12-30 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 30/12/13 06:18, Igor Tandetnik wrote:
> sqlite3_clear_binding is very rarely needed, in my experience. In fact,
> I have not yet encountered a reason to use it.

I use it in my Python wrapper (APSW).  The reason is because I have an
automatic statement cache.  The bindings are cleared before being putting
the statement into the cache to free up any memory (they could have large
blobs or strings) and to make the state of the statement being taken out
of the cache match that of the same one freshly prepared exactly.

I am of the opinion that SQLite should have a statement cache built in
rather than everyone having to implement their own:

  https://www.sqlite.org/src/tktview?name=ee4b2b48f5

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.14 (GNU/Linux)

iEYEARECAAYFAlLB3aYACgkQmOOfHg372QSsFgCgwLkmzGqOrVL9YRLy6gG1E/cC
W+4An1ZFo5njgI0V3i6IAVMrubdGMdQv
=Linf
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to get data between two dates in SQLite with C#?

2013-12-30 Thread Simon Slavin

On 30 Dec 2013, at 1:08am, Fatih BURAL  wrote:

> My name is Fatih, I'm having a trouble about getting data between two 
> different dates in SQLite with C# code.

Things that usually trip up people trying that:

* SQLite doesn't have a DATE type.  You are actually storing INTEGER REAL or 
TEXT and should declare any timedate columns like that.

* If you are doing maths on the dates then you should consider storing them as 
numbers, not strings. If instead you are mostly storing the dates and 
retrieving them for display then it's probably simpler just to store them as 
strings.

* If you are relying on SQLite's functions to process dates in the form 
"-MM-DD HH:MM:SS" then your dates must be in exactly that format.  Four 
digits for the year, two digits for everything else, with all punctuation in 
the right place.


"SELECT * from TABLE t where t.Date1 >= @0 AND t.Date2 <= @1",
date1.ToString("-MM-dd HH:mm:ss"), date2.ToString("-MM-dd HH:mm:ss")

Looking at the above, I suspect that your values 't' break one of the above 
rules.  I assume that "date1" and "date2" are strings in your programming 
language and that you've tested that your "ToString" function does have the 
results you're expecting.

You might usefully use the shell tool to do something like

SELECT Date1, typeof(Date1), Date2, typeof(Date2) FROM t

and check to see that your date fields do have dates at least ten characters 
long with "-" signs in the right place.

Another way to look at the problem is just to forget that it concerns dates at 
all.  You're comparing three strings and your code should work for any strings 
in alphabetic order.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Windows Embedded Handheld 6.5

2013-12-30 Thread Ryan Finnesey
If I want to add a SQLite database to an application I am developing to run on 
Windows Embedded Handheld 6.5 do I need to compile the SQLite Source Code or do 
I just use System.Data.SQLite 
http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki

The development environment is C#  .net compact framework 3.5 and Windows 
Forms.  Windows Embedded Handheld 6.5 is based on Windows Mobile 6.5.3

Thanks for your feedback and help.

Cheers
Ryan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Will It be a Problem that link to 3.7.17 but run on 3.8.2

2013-12-30 Thread Dan Kennedy

On 12/30/2013 10:43 PM, narkewo...@gmail.com wrote:

Hi,

If I have my code compiled/linked agaist a 3.7.17 library on my development
host but run on a target that in fact installed with 3.8.2 library on my
target, will it be a problem? More specifically, will it lead to
database file corruption?


Should be fine. No extra chance of database corruption.



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Will It be a Problem that link to 3.7.17 but run on 3.8.2

2013-12-30 Thread narkewoody
Hi,

If I have my code compiled/linked agaist a 3.7.17 library on my development
host but run on a target that in fact installed with 3.8.2 library on my
target, will it be a problem? More specifically, will it lead to
database file corruption?

Thanks in advance.
-woody

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to get data between two dates in SQLite with C#?

2013-12-30 Thread Eric Teutsch
Hi Fatih,
not tested, but this should work and is I think what you want.  Good luck.

"SELECT * from TABLE t where t.Date1 >= @0 AND t.Date2 <= @1",
date1.ToString("-MM-dd HH:mm:ss"), date2.ToString("-MM-dd HH:mm:ss")


-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of John McKown
Sent: December-30-13 08:05
To: General Discussion of SQLite Database
Subject: Re: [sqlite] How to get data between two dates in SQLite with C#?

Fatih,

I think you'll need to show some code and what it is doing (i.e. I do "..."
and I get "...", but I want "...") before anyone can really help you.


On Sun, Dec 29, 2013 at 7:08 PM, Fatih BURAL  wrote:

> Hi,
>
> My name is Fatih, I'm having a trouble about getting data between two 
> different dates in SQLite with C# code. I tried all the ways even I 
> asked questions about this situation to some MVPs but I didn't solve 
> it. I want to use SQLite but if I don't solve this query I will have 
> to use SQLCE or something that I don't like to use.
>
> Could you please help me to solve that problem?
>
>
>
> Teşekkürler & Saygılar
> Thanks & Regards
> -
> Fatih BURAL
>
> Software Developer
> -
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



--
This is clearly another case of too many mad scientists, and not enough
hunchbacks.

Maranatha! <><
John McKown
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is that same between rebinding every parameter and

2013-12-30 Thread Woody Wu
Thanks, Igor.

On Monday, 30 December 2013, Igor Tandetnik wrote:

> On 12/30/2013 9:14 AM, narkewo...@gmail.com wrote:
>
>> If I don't call sqlite3_clear_binding but rebind every parameter with
>> sqlite3_bind_type before every sqite3_step after sqlite3_reset, will it
>> be any different?
>>
>
> No it won't be. sqlite3_clear_binding is very rarely needed, in my
> experience. In fact, I have not yet encountered a reason to use it.
> --
> Igor Tandetnik
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

narke
public key at http://subkeys.pgp.net:11371 (narkewo...@gmail.com)
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Raheel Gupta
SCHEMA :
CREATE TABLE checksums
(i INTEGER,c VARCHAR(20) PRIMARY KEY) ;

CODE :

// Generates a Random string
QByteArray Randstr_B(int len) {
char chars[36] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
QByteArray str;
for (int i = 0; i < len; i++) {
str.append(chars[qrand() % 35]);
}
return str;
}

// Converts  quint64 to Little Endian bytes
QByteArray toLE(quint64 num){
unsigned char bytes[8];
bytes[0] = (unsigned char)num;
bytes[1] = (unsigned char)(num >> 8);
bytes[2] = (unsigned char)(num >> 16);
bytes[3] = (unsigned char)(num >> 24);
bytes[4] = (unsigned char)(num >> 32);
bytes[5] = (unsigned char)(num >> 40);
bytes[6] = (unsigned char)(num >> 48);
bytes[7] = (unsigned char)(num >> 56);

return QByteArray((const char *)bytes, 8);
}

insQ->prepare("INSERT INTO checksums (i, c) VALUES (?, ?)");

I then do inserts in the loop (I am using QT) :
for(quint64 i = 1; i <= 1000; i++){
// Create the data RANDOMLY
QByteArray block = Randstr_B(4088).append(toLE(i)); // "toLE" is a
function which converts quint64 to Little Endian Bytes i.e. 8 bytes. I used
this to make each block unique
QByteArray csum = QCryptographicHash::hash(block,
QCryptographicHash::Sha1);
unsigned char C = (unsigned char)csum.at(0);

// Insert into the MAP
insQ->bindValue(0, i); // insQ is a QSqlQuery *
insQ->bindValue(1, csum);
if(!insQ->exec()){
qDebug() << "Error Inserting :" << i << csum.toHex().toUpper()
<< insQ->lastError().text();
//exit(0);
}
if((i % 1) == 0){
mapconn.commit(); // Database Connection "mapconn"
Q.exec("PRAGMA wal_checkpoint;"); // Checkpointing the WAL and
"Q" is also another QSqlQuery.
mapconn.transaction(); // Restarting Transaction
qDebug() "Committed :" << i << csum.toHex() << time();
}
}
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Richard Hipp
On Mon, Dec 30, 2013 at 8:56 AM, Raheel Gupta  wrote:

> Sir, I tested the method of the following :
> sqlite3_exec("INSERT OR IGNORE INTO ;");
> if( sqlite3_changes()==0 ){
> sqlite3_exec("UPDATE ...");
> }
> I have seen my performance degrade from 1 records / second to 1
> records / 10 seconds after 3 million UNIQUE Checksums inserted. Am I doing
> anything wrong ? BTW, there were only 10 CONFLICTS in 3 Million rows. So
> they are all unique 20 Byte Sha1 Checksums. I am committing at 1
> inserts.
>

Why don't you provide us with a test case of some kind, or at least your
specific schema and the SQL you are running?


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is that same between rebinding every parameter and

2013-12-30 Thread Igor Tandetnik
On 12/30/2013 9:14 AM, 
narkewo...@gmail.com wrote:

If I don't call sqlite3_clear_binding but rebind every parameter with
sqlite3_bind_type before every sqite3_step after sqlite3_reset, will it
be any different?


No it won't be. sqlite3_clear_binding is very rarely needed, in my 
experience. In fact, I have not yet encountered a reason to use it.

--
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Is that same between rebinding every parameter and

2013-12-30 Thread narkewoody
sqlite3_clear_binding?
Reply-To: 

Hi,

If I don't call sqlite3_clear_binding but rebind every parameter with
sqlite3_bind_type before every sqite3_step after sqlite3_reset, will it
be any different?

Thanks.

-woody
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Raheel Gupta
Sir, I tested the method of the following :
sqlite3_exec("INSERT OR IGNORE INTO ;");
if( sqlite3_changes()==0 ){
sqlite3_exec("UPDATE ...");
}
I have seen my performance degrade from 1 records / second to 1
records / 10 seconds after 3 million UNIQUE Checksums inserted. Am I doing
anything wrong ? BTW, there were only 10 CONFLICTS in 3 Million rows. So
they are all unique 20 Byte Sha1 Checksums. I am committing at 1
inserts.


On Mon, Dec 30, 2013 at 6:38 PM, Richard Hipp  wrote:

> On Mon, Dec 30, 2013 at 7:48 AM, Richard Hipp  wrote:
>
> >
> > The wordcount.c test program does the above using prepared statements and
> > exceeds 348,000 inserts+updates per second on my desktop
> >
>
> Further information:  My desktop is a relatively new and fast SSD machine.
> A 3-year-old ubuntu machine with spinning disks did over 250,000
> inserts+updates per second and a beagleboard black (
> http://beagleboard.org/products/beaglebone%20black) did just shy of 20,000
> inserts+updates per second on the same test case of 791319 insert+updates.
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Richard Hipp
On Mon, Dec 30, 2013 at 7:48 AM, Richard Hipp  wrote:

>
> The wordcount.c test program does the above using prepared statements and
> exceeds 348,000 inserts+updates per second on my desktop
>

Further information:  My desktop is a relatively new and fast SSD machine.
A 3-year-old ubuntu machine with spinning disks did over 250,000
inserts+updates per second and a beagleboard black (
http://beagleboard.org/products/beaglebone%20black) did just shy of 20,000
inserts+updates per second on the same test case of 791319 insert+updates.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to get data between two dates in SQLite with C#?

2013-12-30 Thread John McKown
Fatih,

I think you'll need to show some code and what it is doing (i.e. I do "..."
and I get "...", but I want "...") before anyone can really help you.


On Sun, Dec 29, 2013 at 7:08 PM, Fatih BURAL  wrote:

> Hi,
>
> My name is Fatih, I'm having a trouble about getting data between two
> different dates in SQLite with C# code. I tried all the ways even I asked
> questions about this situation to some MVPs but I didn't solve it. I want
> to use SQLite but if I don't solve this query I will have to use SQLCE or
> something that I don't like to use.
>
> Could you please help me to solve that problem?
>
>
>
> Teşekkürler & Saygılar
> Thanks & Regards
> -
> Fatih BURAL
>
> Software Developer
> -
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
This is clearly another case of too many mad scientists, and not enough
hunchbacks.

Maranatha! <><
John McKown
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] How to get data between two dates in SQLite with C#?

2013-12-30 Thread Fatih BURAL
Hi,

My name is Fatih, I'm having a trouble about getting data between two different 
dates in SQLite with C# code. I tried all the ways even I asked questions about 
this situation to some MVPs but I didn't solve it. I want to use SQLite but if 
I don't solve this query I will have to use SQLCE or something that I don't 
like to use. 

Could you please help me to solve that problem?



Teşekkürler & Saygılar
Thanks & Regards
-
Fatih BURAL

Software Developer
-
  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Richard Hipp
On Mon, Dec 30, 2013 at 5:24 AM, Raheel Gupta  wrote:

> Hi,
>
> I have the following tables :
> CREATE TABLE checksums
> (i INTEGER,c VARCHAR(16) PRIMARY KEY) ;
>
> CREATE TABLE data
> (i INTEGER, data BLOB, isUnique INTEGER)
>
> My application needs to insert 1000s of rows/second into the data table
> hence I use transactions and prepare statements.
>
> Now is it possible that while inserting (using transactions) in the
> Checksums table when there is a CONFLICT as per the column "c" I update
> table "data" column isUnique with the corresponding ID "i" from table
> checksums.
>
> Something like :
> INSERT INTO checksums (1000, "abcdefghijklmnop") ON CONFLICT IGNORE BUT
> UPDATE data SET isUnique = OLD.checksums.i
>

The wordcount.c test program (see
http://www.sqlite.org/src/artifact/9915e06cb) demonstrates four different
ways to do this.  One example:

   sqlite3_exec("INSERT OR IGNORE INTO ;");
   if( sqlite3_changes()==0 ){
 sqlite3_exec("UPDATE ...");
   }

The wordcount.c test program does the above using prepared statements and
exceeds 348,000 inserts+updates per second on my desktop when compiled
using GCC version 4.8.1 and -Os. See
http://www.sqlite.org/src/artifact/9915e06cb?ln=432-445 for the inner loop.



>
> I know the above ON CONFLICT statement is wrong but I need a similar
> functionality.
>
> Is this possible with HOOKS / triggers or anything at all ?
> This will be a great feature if its there.
>
> Regards
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Clemens Ladisch
Raheel Gupta wrote:
>INSERT INTO checksums (1000, "abcdefghijklmnop") ON CONFLICT IGNORE BUT
>UPDATE data SET isUnique = OLD.checksums.i
>
>Is this possible with HOOKS / triggers or anything at all ?

It is possible with the obvious and simple solution: check for
uniqueness with a SELECT, then execute either INSERT or
UPDATE as needed.

Is there any reason that you do not want to use this?


Regards,
Clemens

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Hook / Trigger for Primary Key / Unique Error

2013-12-30 Thread Raheel Gupta
Hi,

I have the following tables :
CREATE TABLE checksums
(i INTEGER,c VARCHAR(16) PRIMARY KEY) ;

CREATE TABLE data
(i INTEGER, data BLOB, isUnique INTEGER)

My application needs to insert 1000s of rows/second into the data table
hence I use transactions and prepare statements.

Now is it possible that while inserting (using transactions) in the
Checksums table when there is a CONFLICT as per the column "c" I update
table "data" column isUnique with the corresponding ID "i" from table
checksums.

Something like :
INSERT INTO checksums (1000, "abcdefghijklmnop") ON CONFLICT IGNORE BUT
UPDATE data SET isUnique = OLD.checksums.i

I know the above ON CONFLICT statement is wrong but I need a similar
functionality.

Is this possible with HOOKS / triggers or anything at all ?
This will be a great feature if its there.

Regards
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users