Re: [sqlite] [SPAM?] Re: [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Keith Medcalf
On Monday, 22 July, 2019 08:18, Richard Damon : >But he was to be able to provide the args as {‘0’:’one, ‘10’:’ten’} >and since he only uses positional rags 1 and 10 that it be OK, i.e. >positional args are treated as key word args, and only those actually >used are needed. THAT can’t be

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread x
Would sqlite3_expanded_sql(stmt) be of any use? https://sqlite.org/c3ref/expanded_sql.html From: sqlite-users on behalf of test user Sent: Monday, July 22, 2019 1:36:25 PM To: SQLite mailing list Subject: Re: [sqlite] [EXTERNAL] Determining valid

Re: [sqlite] [SPAM?] Re: [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Richard Damon
But he was to be able to provide the args as {‘0’:’one, ‘10’:’ten’} and since he only uses positional rags 1 and 10 that it be OK, i.e. positional args are treated as key word args, and only those actually used are needed. THAT can’t be provided by the API. > On Jul 22, 2019, at 9:22 AM, Keith

Re: [sqlite] Determining valid statement placeholders.

2019-07-22 Thread Clemens Ladisch
test user wrote: > I want my library to be able to detect the problem programatically. > > I think SQLite internally knows how many placeholders are in the query at > parse time. > > My question is how can I get the data via the API At the moment, there is no such mechanism in the API. You could

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Keith Medcalf
I don't see what is so hard. APSW does it: >python Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import apsw >>> db = apsw.Connection('') >>> db.execute('select ?, ?10;',

Re: [sqlite] [SPAM?] Re: [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Richard Damon
The problem is you are defining your problem differently than SQLite does, so it can’t help you. To SQLite, a query with ?10 in it has (at least) 10 positional parameters, and if you are defining that the user needs to explicitly provide values for all parameters, (by SQLite) that means they

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Hick Gunter
This cannot be determined programatically. The query generator stores an OP_Variable opcode when the SQL program needs to access the contents of an SQL parameter, and keeps track of the highest parameter number used, which determines the size of the parameter array. Even if you were to examine

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Richard Hipp
On 7/22/19, test user wrote: > > I think SQLite internally knows how many placeholders are in the query at > parse time. SQLite knows the *maximum" placeholder. If you say: INSERT INTO t1(x) VALUES(?100); Then it allocates an array of 100 placeholders. It does not know that the first 99

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Hick Gunter
The question you are asking is properly adressed by the logic that creates the statements itself. The statement generator itself needs to keep track of the SQL parameters it has created and that something has been bound for each parameter before issuing a call to sqlite3_step. Note that as far

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread test user
I understand the problem, but I want my library to be able to detect the problem programatically. Currently if a user mixes index-based and key-based placeholders, the only thing a library using SQLite can do us run the query with unbound placeholders set to null (the SQLite default). Id like

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Keith Medcalf
On Monday, 22 July, 2019 04:34, Enzo wrote: >It is not the same information. >I want to be able to determine "has the user bound all placeholder >values with data?". >The user provides this as input: >query="SELECT ?, ?10" >data={"0": "data-a", "10": "data-b"} >Note: This IS valid, as they

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Enzo
It is not the same information. I want to be able to determine "has the user bound all placeholder values with data?". The user provides this as input: query="SELECT ?, ?10" data={"0": "data-a", "10": "data-b"} Note: This IS valid, as they have provided all data for placeholders. Using the

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread Simon Slavin
On 22 Jul 2019, at 10:53am, test user wrote: > A new function could be added: > > For query string "SELECT ?, ?10" > > `sqlite3_bind_parameter_valid_indexes() -> [1, 10]` > > How can I propose adding this? As given in my previous response, the SQLite library already contains these two: int

Re: [sqlite] [EXTERNAL] Determining valid statement placeholders.

2019-07-22 Thread test user
Simon Slavin: "Please don't use numbers as names." The manual states: - "?NNN": where N is an *integer*. - "?": Programmers are encouraged to use one of the symbolic formats below or the ?NNN format above instead." The use case: I am creating a library that takes SQL from the application and

[sqlite] DROP TABLE while a cursor is open leads to SQLITE_LOCKED

2019-07-22 Thread Jürgen Baier
Hi, I'm using the Xerial JDBC driver for accessing SQLite. I have the problem that it is not possible to drop a table in the same database connection while a resultset is open: 0. Preparation: Create table t1 and add some values 1. Open connection 2. Create temporary table tmp1 3. Execute