[sqlite] Getting all changes within a begin; end; transaction

2020-03-04 Thread Jose Isaias Cabrera
Greetings. Imagine this SQL, BEGIN TRANSACTION; ... changes to records ... END; When I execute "int result = sqlite3_changes(database);" after that SQL execution, I always get 1. I think that it is because it is only providing the result of the last statement that was successful within the

Re: [sqlite] Shell Feature Request: spaces before dot commands

2020-03-04 Thread Simon Slavin
On 4 Mar 2020, at 12:19pm, no...@null.net wrote: >I like to sometimes indent a block of SQL and change > settings or run dot commands within a transaction, e.g.: > >BEGIN >.mode csv >.import ... >COMMIT; Dot commands are not SQL commands, they are instructions to the

[sqlite] Shell Feature Request: spaces before dot commands

2020-03-04 Thread nomad
[SQLite version 3.22.0 2017-11-27 17:56:14] The SQLite shell only recognizes .dot commands without leading spaces. For clarity I like to sometimes indent a block of SQL and change settings or run dot commands within a transaction, e.g.: BEGIN .mode csv .import ... COMMIT;

Re: [sqlite] How should I use the sqlite3 tool?(for linux)

2020-03-03 Thread nomad
On Tue Mar 03, 2020 at 05:12:17PM +0800, suanzi wrote: > Thank you,you let me know what happened. > > About your answer,I try it,but it can't work,maybe because can't have two > zlib. > > apt-get could not find zlib:i386. Did you specifically try "zlib1g"? I don't think the "zlib" package

[sqlite] Updates to althttpd.c for LetsEncrypt compatibility

2020-03-03 Thread Richard Hipp
TL;DR: If you are using althttpd.c on your website, you will need to get the latest code and recompile before the next time you need to get a cert from LetsEncrypt. There are no (known) vulnerabilities or problems with althttpd.c. This is merely an update for LetsEncrypt compatibility due to

[sqlite] FaceBook reduced Messenger size partly through increased use of SQLite

2020-03-03 Thread Shane Harrelson
FaceBook significantly reduced the size of its Messenger app partly by relying on SQLite to do more of the heavy lifting: "Project LightSpeed: How Facebook shrunk Messenger down by 75%" https://www.fastcompany.com/90470219/project-lightspeed-how-facebook-shrunk-messenger-down-by-75 "With

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-03 Thread Dominique Devienne
On Mon, Mar 2, 2020 at 6:35 PM Keith Medcalf wrote: > Well, in theory an order by in a nested select means that the result of the > operation is an ordered projection and not merely a set of rows. > For this particular case (a nested select with an order by and the outer > query with an

Re: [sqlite] How should I use the sqlite3 tool?(for linux)

2020-03-03 Thread suanzi
Thank you,you let me know what happened. About your answer,I try it,but it can't work,maybe because can't have two zlib. apt-get could not find zlib:i386. And there have not sqlite3 tool for linux x64 in sqlite.org Anyway,thank you,I plan download the sqlite source and compile.

Re: [sqlite] How should I use the sqlite3 tool?(for linux)

2020-03-03 Thread Rowan Worth
This means you're missing a dependency - in this case zlib. It's hard to believe you don't have zlib on your system at all; probably this is happening because your system is amd64 but the sqlite binary you've downloaded is x86. I'm not a debian user but this should get you going: apt-get install

Re: [sqlite] How should I use the sqlite3 tool?(for linux)

2020-03-03 Thread suanzi
My OS is Debian10 amd64,desktop is xfce4 ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

[sqlite] How should I use the sqlite3 tool?(for linux)

2020-03-03 Thread suanzi
After I download the tool,I cd to the path,then,I run "./sqlite3" But It can't work,here are error msgs: ./sqlite3: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory So,What should I do for it?

Re: [sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Richard Hipp
On 3/2/20, Keith Medcalf wrote: > > Perhaps this is the same constant propagation bug that was fixed recently? > So it seems. https://sqlite.org/src/timeline?bid=ya65c8d4e26n3bfa9cc97dn7d8dcfb95cy14d14eb537y109ee07433nabfb043ebbne0c6b8bdb7yc9a8defcef -- D. Richard Hipp d...@sqlite.org

Re: [sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Keith Medcalf
Perhaps this is the same constant propagation bug that was fixed recently? -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original Message- >From: sqlite-users On >Behalf Of Keith Medcalf >Sent: Monday, 2 March,

Re: [sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Keith Medcalf
No reproduco SQLite version 3.32.0 2020-03-02 22:04:51 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> CREATE TABLE t ( ...> textid TEXT ...> ); sqlite> INSERT INTO t ...> VALUES ('12');

Re: [sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Jose Isaias Cabrera
Right, Yinyue. Apologies. I actually thought I had built it. Thanks. From: sqlite-users on behalf of Xinyue Chen Sent: Monday, March 2, 2020 06:40 PM To: SQLite mailing list Subject: Re: [sqlite] Report bug found in SQLite version 3.31.1 Hi josé, This

Re: [sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Xinyue Chen
Hi josé, This bug is found in 3.31.1 but you are running it in 3.30.1. Best, Xinyue Chen On Mon, Mar 2, 2020 at 3:36 PM Jose Isaias Cabrera wrote: > Xinyue Chen, on Monday, March 2, 2020 06:21 PM, wrote... > > > > Hi, > > > > I found a bug in the most recent SQLite release version 3.31.1 >

Re: [sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Jose Isaias Cabrera
Xinyue Chen, on Monday, March 2, 2020 06:21 PM, wrote... > > Hi, > > I found a bug in the most recent SQLite release version 3.31.1 2020-01-27. > My initial test environment is macOS 10.14.6 (18G87) and I have tested in > https://sqliteonline.com/. > > CREATE TABLE t ( > textid TEXT > ); >

[sqlite] Report bug found in SQLite version 3.31.1

2020-03-02 Thread Xinyue Chen
Hi, I found a bug in the most recent SQLite release version 3.31.1 2020-01-27. My initial test environment is macOS 10.14.6 (18G87) and I have tested in https://sqliteonline.com/. CREATE TABLE t ( textid TEXT ); INSERT INTO t VALUES ('12'); INSERT INTO t VALUES ('34'); CREATE TABLE i ( intid

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-02 Thread Keith Medcalf
On Monday, 2 March, 2020 09:20, Dominique Devienne wrote: >On Mon, Mar 2, 2020 at 5:09 PM Keith Medcalf wrote: >> select group_concat(value) from (select distinct value from test order by >> value); >But is that guaranteed to be ordered correctly "forever" instead of by >"happenstance" from

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-02 Thread Dominique Devienne
On Mon, Mar 2, 2020 at 5:09 PM Keith Medcalf wrote: > select group_concat(value) from (select distinct value from test order by > value); But is that guaranteed to be ordered correctly "forever" instead of by "happenstance" from current implementation details? My point was that the Window

Re: [sqlite] Intersecting multiple queries

2020-03-02 Thread Hamish Allan
Thanks Jens and everyone. I'll try the approach of compiling statements on the fly. Best wishes, Hamish On Sat, 29 Feb 2020 at 23:13, Jens Alfke wrote: > > > On Feb 28, 2020, at 11:49 PM, Hamish Allan wrote: > > > > Again, I may be making incorrect assumptions. > > Remember the old Knuth

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-02 Thread Keith Medcalf
You mean like: select group_concat(value) over (order by value rows between unbounded preceding and unbounded following) from (select distinct value from test) limit 1; and select group_concat(value) over (order by value desc rows between unbounded preceding and unbounded following) from

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-02 Thread Dominique Devienne
On Sun, Mar 1, 2020 at 10:58 PM mailing lists wrote: > Are there any other solutions / possibilities? I thought someone more knowledgeable than I about Window Functions [1] would answer, but since nobody mentioned them so far, I'll do it, as I believe this is the "SQL native" way to achieve what

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-02 Thread Jean-Luc Hainaut
On 1/03/2020 22:57, mailing lists wrote: Assume I create the following table: CREATE TABLE Test (ID INTEGER PRIMARY KEY, Value TEXT); INSERT INTO Test (Value) VALUES('Alpha'); INSERT INTO Test (Value) VALUES('Beta'); INSERT INTO Test (Value) VALUES('Beta'); INSERT INTO Test (Value)

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-02 Thread mailing lists
Hi Keith, thanks for the explanation. PS: I used a CTE because official examples (e.g. Mandelbrot) also used CTEs in combination with group_concat. Although the incorporation of group_concat was not the primary reason to use CTEs. PPS: Is it possible to rephrase the documentation for

Re: [sqlite] How to enforce a specific order of group_concat?

2020-03-01 Thread Keith Medcalf
On Sunday, 1 March, 2020 14:58, mailing lists wrote: >Assume I create the following table: >CREATE TABLE Test (ID INTEGER PRIMARY KEY, Value TEXT); >INSERT INTO Test (Value) VALUES('Alpha'); >INSERT INTO Test (Value) VALUES('Beta'); >INSERT INTO Test (Value) VALUES('Beta'); >INSERT INTO Test

[sqlite] Write complete pages to journal in VFS?

2020-03-01 Thread J Decker
I've recently changed the underlaying file system driver such that it allocates one of 2 sizes of blocks (4096 or 256), based on how much is written to the file at a time; so a write < 2048 will allocate 256 byte blocks instead; it's not a HUGE performance hit, but I am trying to keep it more on

[sqlite] How to enforce a specific order of group_concat?

2020-03-01 Thread mailing lists
Assume I create the following table: CREATE TABLE Test (ID INTEGER PRIMARY KEY, Value TEXT); INSERT INTO Test (Value) VALUES('Alpha'); INSERT INTO Test (Value) VALUES('Beta'); INSERT INTO Test (Value) VALUES('Beta'); INSERT INTO Test (Value) VALUES('Alpha'); According to the documentation of

Re: [sqlite] Intersecting multiple queries

2020-02-29 Thread Jens Alfke
> On Feb 28, 2020, at 11:49 PM, Hamish Allan wrote: > > Again, I may be making incorrect assumptions. Remember the old Knuth quote about the danger of premature optimization. What’s the size of your data set? Have you tried making a dummy database of the same size and experimenting with

Re: [sqlite] CSV import using CLI (header, NULL)

2020-02-29 Thread Warren Young
On Feb 27, 2020, at 11:51 PM, Christof Böckler wrote: > > 1. There should be no penalty for using header lines in CSV files. Thus a new > flag -h for .import is much appreciated. More than that, SQLite should be able to *actively use* the header when present. For instance, given: foo,bar,qux

Re: [sqlite] Select statement with ORDER BY specified by column value

2020-02-29 Thread Keith Medcalf
SELECT prop_value FROM Table1 WHERE obj_id=10 AND prop_key='key1' AND (prop_tag='ios' OR prop_tag='*') ORDER BY prop_tag == 'ios' DESC LIMIT 1; You want to order by prop_tag == 'ios' in DESCENDING order. That is, the true (1) before the false (0). The default ascending sort will sort the

Re: [sqlite] After column add, what should be done to update the schema?

2020-02-29 Thread Anthony DeRobertis
On 2/27/20 7:03 PM, Andy KU7T wrote: Hi, I use a simple ALTER TABLE ADD COLUMN statement. However, when I use the Sqlite Expert, the DDL is not reflected. One thing to be aware of is that when SQLite adds the column, it often doesn't format it like you'd expect. For example: CREATE TABLE

Re: [sqlite] CSV import using CLI (header, NULL)

2020-02-29 Thread Dominique Devienne
On Sat, Feb 29, 2020 at 1:42 PM Shawn Wagner wrote: > To import a csv file with headers into an existing table, you can use > .import '| tail -n +2 yourfile.csv' yourtable > to skip the header line. On unix. And by shell’ing out to native tools, so not portable. The cli ought to have something

Re: [sqlite] CSV import using CLI (header, NULL)

2020-02-29 Thread Shawn Wagner
To import a csv file with headers into an existing table, you can use .import '| tail -n +2 yourfile.csv' yourtable to skip the header line. On Sat, Feb 29, 2020, 4:30 AM Christof Böckler wrote: > Hi, > > I want to share some thoughts and make some suggestions about the SQLite > 3 command

[sqlite] CSV import using CLI (header, NULL)

2020-02-29 Thread Christof Böckler
Hi, I want to share some thoughts and make some suggestions about the SQLite 3 command line interface (CLI) tool, especially its behaviour when importing CSV files. CSV files are probably even more common for data exchange than SQLite database files. I consider it to be good practice to

Re: [sqlite] Select statement with ORDER BY specified by column value

2020-02-29 Thread Simon Slavin
On 29 Feb 2020, at 8:37am, Marco Bambini wrote: > ORDER BY (prop_tag='ios') LIMIT 1; > > I would like to prioritise results based on the fact that the prop_tag column > is 'ios'. SQLite has a conditional construction: CASE prop_tag WHEN 'ios' THEN 0 ELSE 1 END So do SELECT … ORDER BY

[sqlite] Select statement with ORDER BY specified by column value

2020-02-29 Thread Marco Bambini
Hi all, Is there a way to specify an ORDER BY clause by column value? I have a table declared as: CREATE TABLE Table1 (id INTEGER PRIMARY KEY AUTOINCREMENT, obj_id INTEGER, prop_key TEXT, prop_value TEXT, prop_tag TEXT DEFAULT '*', UNIQUE(obj_id, prop_key, prop_tag)) and a sample query:

Re: [sqlite] Intersecting multiple queries

2020-02-28 Thread Hamish Allan
On Sat, 29 Feb 2020 at 00:45, Keith Medcalf wrote: > > In other words, why would one want to do: > > select * from data where uuid in (select uuid from data where twit == 1 > INTERSECT select uuid from data where twat == 1 INTERSECT select uuid from > data where lastname like 'cricket%'

Re: [sqlite] Intersecting multiple queries

2020-02-28 Thread Simon Slavin
On 29 Feb 2020, at 12:45am, Keith Medcalf wrote: > select * from data where (...) AND (...) AND (...) ; SELECT uuid FROM Data WHERE filter LIKE ? OR filter LIKE ? OR filter LIKE ? OR filter LIKE ? … would probably be an efficient way to do it if you could construct your

Re: [sqlite] Intersecting multiple queries

2020-02-28 Thread Keith Medcalf
Of course, you could just as well do: select * from data where (...) AND (...) AND (...) ; and do away with all the extraneous stuff. In other words, why would one want to do: select * from data where uuid in (select uuid from data where twit == 1 INTERSECT select uuid from data where twat

Re: [sqlite] Intersecting multiple queries

2020-02-28 Thread Keith Medcalf
select stuff from data where uuid in (select uuid from data where ... INTERSECT select uuid from data where ... INTERSECT select uuid from data where ... ); -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original

Re: [sqlite] Intersecting multiple queries

2020-02-28 Thread Simon Slavin
On 28 Feb 2020, at 11:02pm, Hamish Allan wrote: > What I'm wondering is if there's a shortcut to avoid having to build the UUID > list in app code I would probably start by building a list of the search patterns then see what I could do with it: (pattern1,pattern2,pattern3) Would a Common

[sqlite] Intersecting multiple queries

2020-02-28 Thread Hamish Allan
Hi, I am building a list of UUIDs from multiple queries of the form: SELECT uuid FROM Data WHERE filter LIKE ? with a different bound parameter each time. In app-space code, I'm getting the results of these queries and intersecting them, so that the final list contains only UUIDs returned by

Re: [sqlite] After column add, what should be done to update the schema?

2020-02-28 Thread Lee Gray
I just tried it in v5.3.5.470 and v5.3.5.472 and it worked fine. From: sqlite-users On Behalf Of Andy KU7T Sent: Thursday, February 27, 2020 6:03 PM To: SQLite mailing list Subject: [sqlite] After column add, what should be done to update the schema? Hi, I use a simple ALTER TABLE ADD COLUMN

Re: [sqlite] After column add, what should be done to update the schema?

2020-02-28 Thread David Raymond
"I read somewhere that the DDL is really just a copy of the text when teh table was created" It starts that way, but the ALTER TABLE command will update that string when it runs so that it reflects the new column. Did you commit your changes after the alter table and before looking for the

Re: [sqlite] After column add, what should be done to update the schema?

2020-02-27 Thread Keith Medcalf
Probably a bug. SQLiteExpert does not even run on my computer. It just farts in the wind and does not even bother to log or show an error message. Maybe it tries to access some internal Microsoft Spying mechanism that I have disabled. -- The fact that there's a Highway to Hell but only a

Re: [sqlite] After column add, what should be done to update the schema?

2020-02-27 Thread Jean-Christophe Deschamps
Bonjour, I use a simple ALTER TABLE ADD COLUMN statement. However, when I use the Sqlite Expert, the DDL is not reflected. Even though the column is created. I read somewhere that the DDL is really just a copy of the text when teh table was created. Is there a way to refresh this? I can't

[sqlite] After column add, what should be done to update the schema?

2020-02-27 Thread Andy KU7T
Hi, I use a simple ALTER TABLE ADD COLUMN statement. However, when I use the Sqlite Expert, the DDL is not reflected. Even though the column is created. I read somewhere that the DDL is really just a copy of the text when teh table was created. Is there a way to refresh this? Thanks, Andy

Re: [sqlite] sqlite-users Digest, Vol 146, Issue 27

2020-02-27 Thread Balaji Ramanathan
On Thu, Feb 27, 2020 at 6:00 AM < sqlite-users-requ...@mailinglists.sqlite.org> wrote: > 18. Cannot export 'sqlite3' file to CSV (Rachael Courts) > From: Rachael Courts > To: "sqlite-users@mailinglists.sqlite.org" < > sqlite-users@mailinglists.sqlite.org> > Cc: > Bcc: > Date: Thu, 27 Feb 2020

Re: [sqlite] Issues with sqlite3session_attach(conn, NULL) w/ duplicate table in temp

2020-02-27 Thread Adam Levy
Dan, I tried the above patch and it resolves the issue! Also you were right about use of "*" in attach. I misinterpreted the output of my test in that case. Thank you so much for taking the time to fix this! When can I expect this patch to make it into a release? Adam Levy On Thu, Feb 27, 2020

Re: [sqlite] Issues with sqlite3session_attach(conn, NULL) w/ duplicate table in temp

2020-02-27 Thread Dan Kennedy
On 27/2/63 05:04, Adam Levy wrote: Hi all When I have a database connection with a temp table of the same name as a table in main, I am getting what I feel is unexpected behavior from the session extension. Most succinctly, I start a session on a connection on the main db with a table with an

Re: [sqlite] Cannot export 'sqlite3' file to CSV

2020-02-27 Thread sky5walk
Easier still: Install https://nightlies.sqlitebrowser.org/latest/ Then open your sqlite database(s) directly within the browser. There you can run queries and/or export to csv. On Thu, Feb 27, 2020, 4:54 AM Shawn Wagner wrote: > Use the standard sqlite3 shell program: >

Re: [sqlite] VFS xFullPathname cannot access URI parameters

2020-02-27 Thread Richard Hipp
On 2/26/20, Chris Warner wrote: > In 3.31.1, attempting to access URI Parameters via the sqlite3_uri_* > functions inside a VFS xFullPathname function returns junk. This was not an > issue in 3.30.1 or 3.31.0. > SQLite does not promise that sqlite3_uri_parameter() will work for the argument

Re: [sqlite] Cannot export 'sqlite3' file to CSV

2020-02-27 Thread Shawn Wagner
Use the standard sqlite3 shell program: https://www.sqlite.org/cli.html#csv_export On Thu, Feb 27, 2020, 1:48 AM Rachael Courts wrote: > Hi All, > > I'm a couple of months into my PhD, studying bioacoustics. I am using > SQLiteStudio to open '.sqlite3' files, which I need to convert to CSV

[sqlite] Cannot export 'sqlite3' file to CSV

2020-02-27 Thread Rachael Courts
Hi All, I'm a couple of months into my PhD, studying bioacoustics. I am using SQLiteStudio to open '.sqlite3' files, which I need to convert to CSV files to import into MATLAB for further analyses. Currently I have attempted the data export function, selecting which database and table I would

Re: [sqlite] Error/Result code documentation

2020-02-26 Thread Dominique Devienne
On Wed, Feb 26, 2020 at 11:09 AM Dominique Devienne wrote: > Hi. In the doc excerpt below from https://www.sqlite.org/rescode.html > are the $n*Code variables supposed to be expanded with a numeric > value, and there's a little issue in the doc generation? Thanks, --DD Thanks for the fix

Re: [sqlite] How to prevent sqlite_reset reporting an already known error

2020-02-26 Thread Simon Slavin
On 26 Feb 2020, at 11:58pm, mailing lists wrote: > The issue is that sqlite_reset() reports the same error that already > sqlite3_step() reported. How can I prevent that sqlite_reset() reports the > same error. You can't. It's working as designed. One would normally test the result that

[sqlite] How to prevent sqlite_reset reporting an already known error

2020-02-26 Thread mailing lists
I am executing a prepared statement S with a couple of different bindings. The execution sequence is similar to this while (moreBindings) { bind_parameters_to_prepared_statement; sqlite3_step(); if (error) { … } sqlite_reset(); if (error) { } } The issue is that sqlite_reset() reports the

[sqlite] VFS xFullPathname cannot access URI parameters

2020-02-26 Thread Chris Warner
In 3.31.1, attempting to access URI Parameters via the sqlite3_uri_* functions inside a VFS xFullPathname function returns junk.  This was not an issue in 3.30.1 or 3.31.0. The internals of those functions use the new databaseName() function, which attempts to find the database name from the

[sqlite] Issues with sqlite3session_attach(conn, NULL) w/ duplicate table in temp

2020-02-26 Thread Adam Levy
Hi all When I have a database connection with a temp table of the same name as a table in main, I am getting what I feel is unexpected behavior from the session extension. Most succinctly, I start a session on a connection on the main db with a table with an INTEGER PRIMARY KEY, attach it to all

Re: [sqlite] Trigger name missing

2020-02-26 Thread Jean-Luc Hainaut
On 26/02/2020 12:18, Richard Hipp wrote: On 2/26/20, Jean-Luc Hainaut wrote: Hi all, It seems that SQLite (version 31.1) accepts a trigger declaration in which the name is missing. When fired, this trigger doesn't crashes but exhibits a strange behaviour. In particular, while expression

[sqlite] [feature request] Quirk-fixing compile-time options

2020-02-26 Thread Joshua Wise
Hi, I was very happy to see the addition of the SQLITE_DQS compile-time option, which fixes one of the legacy bugs/quirks of SQLite3. I was wondering if additional compile-time options could be added to fix two other legacy quirks: - Primary Keys containing NULLs

Re: [sqlite] Fwd: inserting new data only

2020-02-26 Thread Jose Isaias Cabrera
James K. Lowden, on Wednesday, February 26, 2020 11:55 AM, wrote... > > On Tue, 25 Feb 2020 12:02:24 -0500 > Przemek Klosowski wrote: > > > and I want to avoid storing repetitive data, so that the database > > should contain > > 10:32 12 > > 10:35 15 > > 10:39 13 > > 10:46 18 > > where only

Re: [sqlite] inserting new data only

2020-02-26 Thread Simon Slavin
On 26 Feb 2020, at 5:18pm, Przemek Klosowski wrote: > This 'store only changed values' is > intended for situations like that. > Another suitable candidate for that treatment might be a status, for > instance 'on battery' value for a UPS monitoring system. I can't think of a > scenario where

Re: [sqlite] Fwd: inserting new data only

2020-02-26 Thread Przemek Klosowski
On Wed, Feb 26, 2020 at 11:56 AM James K. Lowden wrote: > > and I want to avoid storing repetitive data, so that the database > > should contain > > [...] > > only the earliest time with the unchanging value is stored. > > Be careful what you wish for. Usually "avoid storing" is a proxy for >

Re: [sqlite] Fwd: inserting new data only

2020-02-26 Thread James K. Lowden
On Tue, 25 Feb 2020 12:02:24 -0500 Przemek Klosowski wrote: > and I want to avoid storing repetitive data, so that the database > should contain > 10:32 12 > 10:35 15 > 10:39 13 > 10:46 18 > where only the earliest time with the unchanging value is stored. Be careful what you wish for.

Re: [sqlite] Trigger name missing

2020-02-26 Thread Jose Isaias Cabrera
SQLite is even better than I thought... From: sqlite-users on behalf of Richard Hipp Sent: Wednesday, February 26, 2020 11:44 AM To: SQLite mailing list Subject: Re: [sqlite] Trigger name missing On 2/26/20, Simon Slavin wrote: > > Backward compatibility ?

Re: [sqlite] Trigger name missing

2020-02-26 Thread Richard Hipp
On 2/26/20, Simon Slavin wrote: > > Backward compatibility ? Do you think anyone who used the word AFTER > really wants a BEFORE trigger ? More likely to be a bug they should know > about. We have seen triggers like this in the wild, that work as intended. If we change it to throw an error,

Re: [sqlite] Trigger name missing

2020-02-26 Thread Simon Slavin
On 26 Feb 2020, at 2:15pm, Dan Kennedy wrote: > A statement like the following creates a "BEFORE" trigger named "AFTER". Does > that explain things? > > CREATE TRIGGER AFTER INSERT ON t1 BEGIN > ... > END; > > I find I fall into this trap about once every 18 months... If only you

Re: [sqlite] more efficient JSON encoding: idle musing

2020-02-26 Thread Paul van Helden
> > > I experimented with a number of similar ideas for storing JSON when I > was first designing the JSON components for SQLite. I was never able > to find anything that was as fast or as compact as just storing the > original JSON text. > I've also done a lot of experiments and was surprised

Re: [sqlite] Trigger name missing

2020-02-26 Thread Dan Kennedy
On 26/2/63 16:31, Jean-Luc Hainaut wrote: Hi all, It seems that SQLite (version 31.1) accepts a trigger declaration in which the name is missing. When fired, this trigger doesn't crashes but exhibits a strange behaviour. In particular, while expression "new." in an "insert" trigger returns

Re: [sqlite] sqliteDefaultBusyCallback and HAVE_USLEEP

2020-02-26 Thread Peter Kolbus
> On Feb 26, 2020, at 5:53 AM, Graham Holden wrote: > > Wednesday, February 26, 2020, 11:15:14 AM, Richard Hipp > wrote: > >>> On 2/25/20, Peter Kolbus wrote: >>> I noticed that sqliteDefaultBusyCallback() seems to depend directly on the >>> OS (behave differently based on

Re: [sqlite] sqliteDefaultBusyCallback and HAVE_USLEEP

2020-02-26 Thread Graham Holden
Wednesday, February 26, 2020, 11:15:14 AM, Richard Hipp wrote: > On 2/25/20, Peter Kolbus wrote: >> I noticed that sqliteDefaultBusyCallback() seems to depend directly on the >> OS (behave differently based on SQLITE_OS_WIN||HAVE_USLEEP). Since the >> underlying primitive, sqlite3OsSleep(),

Re: [sqlite] Trigger name missing

2020-02-26 Thread Richard Hipp
On 2/26/20, Jean-Luc Hainaut wrote: > Hi all, > > It seems that SQLite (version 31.1) accepts a trigger declaration in > which the name is missing. When fired, this trigger doesn't crashes but > exhibits a strange behaviour. In particular, while expression > "new." in an "insert" trigger returns

Re: [sqlite] sqliteDefaultBusyCallback and HAVE_USLEEP

2020-02-26 Thread Richard Hipp
On 2/25/20, Peter Kolbus wrote: > I noticed that sqliteDefaultBusyCallback() seems to depend directly on the > OS (behave differently based on SQLITE_OS_WIN||HAVE_USLEEP). Since the > underlying primitive, sqlite3OsSleep(), actually uses the VFS to sleep, and > unixSleep() also has a roundup to

Re: [sqlite] unexpected sqlite_busy behaviour within transactions

2020-02-26 Thread Software
Dear Igor, Andy, Keith Thank you for your patience to explain. Now very clear to me why it is not worth for the second process to honor the sqlite_busy handler, and instead returns immediately. In retrospect re-reading with your explanations in mind, I also understand the official

[sqlite] Error/Result code documentation

2020-02-26 Thread Dominique Devienne
Hi. In the doc excerpt below from https://www.sqlite.org/rescode.html are the $n*Code variables supposed to be expanded with a numeric value, and there's a little issue in the doc generation? Thanks, --DD 4. Primary Result Code List The $nPrimCode result codes ... 5. Extended Result Code List

[sqlite] Trigger name missing

2020-02-26 Thread Jean-Luc Hainaut
Hi all, It seems that SQLite (version 31.1) accepts a trigger declaration in which the name is missing. When fired, this trigger doesn't crashes but exhibits a strange behaviour. In particular, while expression "new." in an "insert" trigger returns the correct value, the equivalent

Re: [sqlite] Compiling on AIX OS

2020-02-26 Thread Domingo Alvarez Duarte
Hello and thank you for reply ! As I said it's an exercise to know the peculiarities of compiling on this platform and I'm exposing this experience here in hope it can help others and improve sqlite build system. If what you mention is correct about requiring tcl 8.5 or newer then the

Re: [sqlite] Compiling on AIX OS

2020-02-26 Thread Shawn Wagner
I'm pretty sure the full build scripts require tcl 8.5 or newer. Maybe try the -amalgamation or -autoconf versions? On Wed, Feb 26, 2020 at 1:21 AM Domingo Alvarez Duarte wrote: > Hello ! > > > > $ uname -a > AIX minimal 1 7 00C63E504B00 > $ tclsh > % puts $tcl_patchLevel > 8.4.7 > % >

Re: [sqlite] Compiling on AIX OS

2020-02-26 Thread Domingo Alvarez Duarte
Hello ! $ uname -a AIX minimal 1 7 00C63E504B00 $ tclsh % puts $tcl_patchLevel 8.4.7 % On 26/2/20 10:19, Shawn Wagner wrote: puts $tcl_patchLevel ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Compiling on AIX OS

2020-02-26 Thread Shawn Wagner
What version of tcl do you have installed? (At the tclsh prompt, do a `puts $tcl_patchLevel`) On Wed, Feb 26, 2020 at 1:05 AM Domingo Alvarez Duarte wrote: > Hello ! > > Trying to compile https://sqlite.org/2020/sqlite-src-3310100.zip on AIX > 7.1 operating system for exercise and to know the

Re: [sqlite] Compiling on AIX OS

2020-02-26 Thread Domingo Alvarez Duarte
Going forward after fixing the access mode from "rb" to "r" we get this error (tclsh8.4): tclsh /home/mingo/dev/sqlite-src-3310100/tool/mkshellc.tcl >shell.c cp /home/mingo/dev/sqlite-src-3310100/ext/fts5/fts5parse.y . rm -f fts5parse.h ./lemon  -S fts5parse.y tclsh

[sqlite] Compiling on AIX OS

2020-02-26 Thread Domingo Alvarez Duarte
Hello ! Trying to compile https://sqlite.org/2020/sqlite-src-3310100.zip on AIX 7.1 operating system for exercise and to know the peculiarities of building software on this OS and I'm getting this error, somehow tclsh that is installed on this OS do not wrap/hide OS incompatibilities.

[sqlite] sqliteDefaultBusyCallback and HAVE_USLEEP

2020-02-25 Thread Peter Kolbus
I noticed that sqliteDefaultBusyCallback() seems to depend directly on the OS (behave differently based on SQLITE_OS_WIN||HAVE_USLEEP). Since the underlying primitive, sqlite3OsSleep(), actually uses the VFS to sleep, and unixSleep() also has a roundup to whole seconds when HAVE_USLEEP is not

Re: [sqlite] more efficient JSON encoding: idle musing

2020-02-25 Thread Jens Alfke
> On Feb 25, 2020, at 6:12 AM, J Decker wrote: > > other than that; if space is really a concern, maybe a zip layer? In my experience, the concern is more about speed than size. Given the raw string/blob data from a SQLite column, and a specific property name/path, how fast can you find its

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Keith Medcalf
I keep forgetting that the mix/max optimization is not applied at the same time as retrieving other data from a table, so if you actually want to optimize the generated plan, you need to use the following trigger: create trigger data_insert before insert on data begin select raise(ABORT,

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Keith Medcalf
If you are going to do it in all in one insert statement rather than using a before trigger to throw an error (ie, you want to silently ignore out-of-order inserts) then the following is slightly more efficient since the query planner appears to materialize the search so only does it once:

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Keith Medcalf
On Tuesday, 25 February, 2020 12:23, Przemek Klosowski wrote: >On Tue, Feb 25, 2020 at 1:18 PM Keith Medcalf wrote: >> create table data >> ( >> keytext primary key, >> data integer not null >> ) >> without rowid; >> >> -- insert into data select ?, ? as value where value IS

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread David Raymond
Awesome---exactly what's needed. The monotonicity of the time key variable is assured by how the data is collected---but is there a way to express that in sqlite? create table data ( key text primary key check (julianday(key) > julianday(select max(key) from data), data integer not null);

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Przemek Klosowski
On Tue, Feb 25, 2020 at 1:18 PM Keith Medcalf wrote: > create table data > ( > keytext primary key, > data integer not null > ) > without rowid; > > -- insert into data select (?, ? as value where value IS NOT (select data > from (select max(key), data from data)); >.. >

Re: [sqlite] inserting new data only

2020-02-25 Thread Simon Slavin
This strikes me as best solved in the programming language. If a single set of data points is being acquired in real time, and you have a programming language (or script) generating the INSERT commands, why not simply keep the most recently inserted temperature in a variable ? On the other

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Keith Medcalf
Note that this will work for discrete data from a sensor but will not properly historize continuous data. That is, if what you are historizing is process data such as a temperature, this will not permit you to re-create the original engineering data. For that you need to allow the last

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Keith Medcalf
create table data ( keytext primary key, data integer not null ) without rowid; -- insert into data select (?, ? as value where value IS NOT (select data from (select max(key), data from data)); insert into data select '10:32', 12 as value where value IS NOT (select data from

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Przemek Klosowski
On Tue, Feb 25, 2020 at 1:03 PM John McKown wrote: > > I am storing time series data arriving from a sensor into (time,value) > > records, like so: > > 10:32 12 > > 10:35 15 > > 10:37 15 > > 10:39 13 > > 10:43 13 > > 10:46 18 > > > > and I want to avoid storing repetitive data, so that the

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread Przemek Klosowski
On Tue, Feb 25, 2020 at 12:22 PM David Raymond wrote: > > A before trigger which uses the raise function would stop it from getting > inserted in the first place. > > create trigger cull > before insert on tbl > when new.value = (select value from tbl order by time desc limit 1) > begin > select

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread John McKown
On Tue, Feb 25, 2020 at 11:03 AM Przemek Klosowski < przemek.klosowski+sql...@gmail.com> wrote: > I am storing time series data arriving from a sensor into (time,value) > records, like so: > 10:32 12 > 10:35 15 > 10:37 15 > 10:39 13 > 10:43 13 > 10:46 18 > > and I want to avoid storing

Re: [sqlite] Fwd: inserting new data only

2020-02-25 Thread David Raymond
A before trigger which uses the raise function would stop it from getting inserted in the first place. create trigger cull before insert on tbl when new.value = (select value from tbl order by time desc limit 1) begin select raise(ignore); end; Or if you want it to actually return an error to

[sqlite] Fwd: inserting new data only

2020-02-25 Thread Przemek Klosowski
I am storing time series data arriving from a sensor into (time,value) records, like so: 10:32 12 10:35 15 10:37 15 10:39 13 10:43 13 10:46 18 and I want to avoid storing repetitive data, so that the database should contain 10:32 12 10:35 15 10:39 13 10:46 18 where only the earliest

Re: [sqlite] After deleting data from a FTS table and doing VACUUM, unwanted data remains

2020-02-25 Thread Graham Holden
Tuesday, February 25, 2020, 3:00:09 PM, Luuk wrote: [tests snipped] > So, the index does not grow indefinitely > On 25-2-2020 14:00, Graham Holden wrote: >> It is an interesting problem. And the above is just guesswork... It would >> be good to verify experimentally that the index really does

<    1   2   3   4   5   6   7   8   9   10   >