[sqlite] Enabling FTS on a view

2019-09-01 Thread Amjith Ramanujam
Hi, I've created a view that is a union of two tables. How can I enable FTS for this view? Since views don't have a "rowid" I'm unable to populate the FTS virtual table with the contents of the view. Is there a workaround for this? Thank you! Amjith

Re: [sqlite] SQLITE_BUSY, database is locked in "PRAGMA journal_mode"

2019-09-01 Thread Rowan Worth
On Fri, 30 Aug 2019 at 04:18, test user wrote: > B. Is there any method for determining lock transitions for connections? > - Is there an API? > - Would it be possible to use dtrace to instrument SQLite to detect > lock transitions? > - Where should I be looking? > On unix

Re: [sqlite] select for power-meter accumulated total readings

2019-09-01 Thread Keith Medcalf
Of course, what we are emulating here is called a "Process Historian", common examples being PHD and PI. So, if you make a few minor adjustments, you can make this run just about as fast as a "designed for purpose" Process Historian. The changes are that you need to store the data in an

Re: [sqlite] select for power-meter accumulated total readings

2019-09-01 Thread Keith Medcalf
This will get you the consumption projection for each day in the table (timestamp in s represents the ENDING period you are interested in and you can modify it to whatever interval you want, and of course the final query gets the result). It works by computing the slope from each timestamp to

Re: [sqlite] select for power-meter accumulated total readings

2019-09-01 Thread Petr Jakeš
As far I have ended with following: WITH miniPow as ( select date(TIMESTAMP,'+1 day') as d, max(TOTAL_KWH) mini from power group by date(timestamp) ) , maxiPow as ( select date(TIMESTAMP) as d, max(TOTAL_KWH) maxi from power group by date(timestamp) ) select maxiPow.d, ROUND(maxi-mini, 1) from

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-01 Thread Keith Medcalf
On Sunday, 1 September, 2019 11:12, Alexander Vega wrote: >Thank you Keith for your answer. It has led me to more questions. >"though you may or may not have visited all rows" >From the documentation I did not get the impression that you would >ever not visit ALL ROWS at least once. Is there a

Re: [sqlite] Non-keyword quoted identifiers parsed as string literals

2019-09-01 Thread William Chargin
Thank you both for your quick and helpful replies! The `quirks.html` page certainly clears things up. Glad to see that there are new options to disable this; I reached out to the maintainers of the language bindings that I use to see if we can get that enabled [1]. [1]:

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-01 Thread Alexander Vega
Thank you Keith for your answer. It has led me to more questions. "though you may or may not have visited all rows" From the documentation I did not get the impression that you would ever not visit ALL ROWS at least once. Is there a technical reason for this? I would assume a full table scan is

Re: [sqlite] Non-keyword quoted identifiers parsed as string literals

2019-09-01 Thread Keith Medcalf
On Sunday, 1 September, 2019 00:26, William Chargin wrote: >I tracked down a perplexing issue to the following behavior: >sqlite> CREATE TABLE tab (col); >sqlite> SELECT nope FROM tab; -- fails; good >Error: no such column: nope >sqlite> SELECT "nope" FROM tab; -- works? >

Re: [sqlite] Non-keyword quoted identifiers parsed as string literals

2019-09-01 Thread Ben Kurtovic
> Is this working as intended? Are there plans to make SQLite reject such > examples as malformed queries instead of implicitly coercing? This problematic behavior, including discussion on how to disable it, is documented here: https://www.sqlite.org/quirks.html#dblquote

[sqlite] Non-keyword quoted identifiers parsed as string literals

2019-09-01 Thread William Chargin
I tracked down a perplexing issue to the following behavior: sqlite> CREATE TABLE tab (col); sqlite> SELECT nope FROM tab; -- fails; good Error: no such column: nope sqlite> SELECT "nope" FROM tab; -- works? sqlite> INSERT INTO tab (col) VALUES (77); sqlite> SELECT col