Re: [sqlite] To edit in sqlite3 CLI multiline SQL statements?

2020-01-19 Thread Jose Isaias Cabrera
Simon Slavin, on Saturday, January 18, 2020 04:58 PM, wrote... > > On 18 Jan 2020, at 9:30pm, Csanyi Pal, on > > > can one edit a multiline SQL statement in the sqlite3 CLI? > > No. > > But if you make a multiline SQL statement in a text file you can paste it > into the CLI all in one operation.

Re: [sqlite] Obtaining rowid of an updated row in UPSERT

2020-01-19 Thread Kees Nuyt
On Sun, 19 Jan 2020 17:07:38 +0100, you wrote: >On 16.01.2020 14:02, Daniel Janus wrote: >> Dear SQLiters, >> >> If an INSERT ... ON CONFLICT DO UPDATE statement detects that a row >> already exists and needs to be updated, it doesn't seem to set lastRowid >> to the rowid of that row. Observe

Re: [sqlite] Find schema of a table in a query

2020-01-19 Thread Keith Medcalf
On Sunday, 19 January, 2020 01:47, x wrote: >Suppose you’re given a query ‘SELECT 1 from tbl’ by a user and you want >to know the name of the schema that tbl belongs to. What’s the easiest >way to do this? >I know sqlite will use temp.tbl if it exists else main.tbl if it exists >else it will

[sqlite] Bug? SQLITE_DEFAULT_DEFENSIVE and CLI .parameters

2020-01-19 Thread Keith Medcalf
Defining SQLITE_DEFAULT_DEFENSIVE prevents proper working of the CLI .parameter commands. SQLite version 3.31.0 2020-01-19 18:49:07 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> .schema sqlite> .param

Re: [sqlite] Find schema of a table in a query

2020-01-19 Thread x
If I could answer the “such as” I wouldn’t have asked the question. The word “hoping” is the clue as in I was hoping there was some function I had overlooked. I’ve settled for using the sqlite3_table_column_metadata function in a loop using each db name in turn in the order sqlite3 does.

Re: [sqlite] Obtaining rowid of an updated row in UPSERT

2020-01-19 Thread Daniel Janus
On 16.01.2020 14:02, Daniel Janus wrote: Dear SQLiters, If an INSERT ... ON CONFLICT DO UPDATE statement detects that a row already exists and needs to be updated, it doesn't seem to set lastRowid to the rowid of that row. Observe (sqlite 3.30.1):   > create table users (id integer primary

Re: [sqlite] Find schema of a table in a query

2020-01-19 Thread Warren Young
On Jan 19, 2020, at 2:41 AM, x wrote: > > I was hoping for something simpler. Such as? I mean, your question basically reduces to “I need to be inside the parse loop,” and SQLite has come along and said, “Hey, check this out, you can be inside the parse loop.” I mean, how cool is that?

Re: [sqlite] Find schema of a table in a query

2020-01-19 Thread x
Thanks Dominique. I was aware of that route but I was hoping for something simpler. From: sqlite-users on behalf of Dominique Devienne Sent: Sunday, January 19, 2020 9:32:28 AM To: SQLite mailing list Subject: Re: [sqlite] Find schema of a table in a query

Re: [sqlite] Find schema of a table in a query

2020-01-19 Thread Dominique Devienne
On Sun, Jan 19, 2020 at 9:47 AM x wrote: > Suppose you’re given a query ‘SELECT 1 from tbl’ by a user and you want to > know the name of the schema that tbl belongs to. What’s the easiest way to > do this? Set an authorizer. Requires to write code though, cannot be done in SQL.

[sqlite] Find schema of a table in a query

2020-01-19 Thread x
Suppose you’re given a query ‘SELECT 1 from tbl’ by a user and you want to know the name of the schema that tbl belongs to. What’s the easiest way to do this? I know sqlite will use temp.tbl if it exists else main.tbl if it exists else it will search for the earliest attached schema with a