Re: [sqlite] Is there something like PATH to search for extension libraries?

2020-01-31 Thread Peng Yu
OK. This was not clear to me by reading https://www.sqlite.org/loadext.html. Maybe it should be included by the maintainer of that page. On 2/1/20, Keith Medcalf wrote: > > On Friday, 31 January, 2020 21:15, Peng Yu wrote: > >>I have to specify either a full path (either relative or absolution)

Re: [sqlite] Is there something like PATH to search for extension libraries?

2020-01-31 Thread Keith Medcalf
On Friday, 31 January, 2020 21:15, Peng Yu wrote: >I have to specify either a full path (either relative or absolution) >to use .load. But it would be more convenient if there is something >like PATH (may be named as something like SQLITE3_LIB_PATH) to search >for library files. Is it available

[sqlite] Is there something like PATH to search for extension libraries?

2020-01-31 Thread Peng Yu
Hi, I have to specify either a full path (either relative or absolution) to use .load. But it would be more convenient if there is something like PATH (may be named as something like SQLITE3_LIB_PATH) to search for library files. Is it available in sqlite3? Thanks.

Re: [sqlite] log() in sqlite3

2020-01-31 Thread Keith Medcalf
On Friday, 31 January, 2020 17:59, Peng Yu wrote: >How to use extension-functions.c? It means that I have to compile it? Yes. Either as a loadable extension or as core builtin functions extending the amalgamation. >How to use it with python? db.load_extension() for each connection db into

Re: [sqlite] Is there a way to yield an error when opening a nonexistent dbfile?

2020-01-31 Thread Keith Medcalf
You could use the second method (opening the file by handle) if you do not want your code to be portable. Yes, APSW is far superior to sqlite3. It does not have any "magic" and wraps SQLite3 into Python so that it works like SQLite3 works, so the interface works as documented for the

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Simon Slavin
On 1 Feb 2020, at 1:28am, Simon Slavin wrote: > How do you feel about that ? Sorry, I didn't read the rest of the list first. I see it's already answered. Thanks. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Simon Slavin
On 31 Jan 2020, at 10:51pm, Richard Hipp wrote: > CREATE TABLE t1(x INTEGER CHECK(typeof(x)=='text')); > INSERT INTO t1 VALUES('123'); > PRAGMA integrity_check; Short and sweet. That's what I was talking about. How do you feel about that ? Should a programmer be able to create a failure in

Re: [sqlite] log() in sqlite3

2020-01-31 Thread Peng Yu
How to use extension-functions.c? It means that I have to compile it? How to use it with python? For python, create_function should be a better solution? Thanks. On 1/31/20, Chris Brody wrote: > The log function does seem to be supported by extension-functions.c which > is available from here:

Re: [sqlite] Is there a way to yield an error when opening a nonexistent dbfile?

2020-01-31 Thread Peng Yu
What is the recommended way to do so in python? I see the following two ways. ``` db = sqlite3.connect('file:/path/to/database?mode=ro', uri=True) fd = os.open(filename, os.O_RDONLY) c = sqlite3.connect('/dev/fd/%d' % fd) os.close(fd) ```

Re: [sqlite] Check constrain execution timing change? (Now a bug)

2020-01-31 Thread Richard Hipp
On 1/31/20, Keith Medcalf wrote: > > That would elevate this to the status of a bug since it should be impossible > to do this. > It is also not something that is fixable, so the solution will likely be to simply document it. -- D. Richard Hipp d...@sqlite.org

Re: [sqlite] Check constrain execution timing change? (Now a bug)

2020-01-31 Thread Keith Medcalf
On Friday, 31 January, 2020 14:39, Simon Slavin wrote: >On 31 Jan 2020, at 9:27pm, Keith Medcalf wrote: >> You are however correct that this is an "application consistency" >problem more than an SQLite problem and it is a lot of change for little >actual benefit. >How about this ? >A

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Richard Hipp
CREATE TABLE t1(x INTEGER CHECK(typeof(x)=='text')); INSERT INTO t1 VALUES('123'); PRAGMA integrity_check; On 1/31/20, Graham Holden wrote: > Friday, January 31, 2020, 9:39:07 PM, Simon Slavin > wrote: > >> On 31 Jan 2020, at 9:27pm, Keith Medcalf wrote: > >>> You are however correct that

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Graham Holden
Friday, January 31, 2020, 9:39:07 PM, Simon Slavin wrote: > On 31 Jan 2020, at 9:27pm, Keith Medcalf wrote: >> You are however correct that this is an "application consistency" >> problem more than an SQLite problem and it is a lot of change for >> little actual benefit. > How about this ?

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Simon Slavin
On 31 Jan 2020, at 9:27pm, Keith Medcalf wrote: > You are however correct that this is an "application consistency" problem > more than an SQLite problem and it is a lot of change for little actual > benefit. How about this ? A program (possibly part of the SQLite precompiled suite, possibly

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Keith Medcalf
On Friday, 31 January, 2020 13:58, Richard Hipp wrote: >On 1/31/20, Keith Medcalf wrote: >> The check should occur AFTER defaults and >> column affinity is applied before the data record is stored >Why do you think this? Is it documented somewhere? I ask because >your test case gives the

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Keith Medcalf
>collect input data row >apply column affinity >fire before triggers >apply defaults, generated always, rowid etc. >apply column affinity to above columns >run constraints >store actul row >fire after triggers Actually, with generated columns it is a bit more complicated. I think: collect input

Re: [sqlite] Check constrain execution timing change?

2020-01-31 Thread Richard Hipp
On 1/31/20, Keith Medcalf wrote: > > The check should occur AFTER defaults and > column affinity is applied before the data record is stored > Why do you think this? Is it documented somewhere? I ask because your test case gives the same answer (doing the first insert but failing the other

[sqlite] Check constrain execution timing change?

2020-01-31 Thread Keith Medcalf
I believe that when inserting a row into a table the CHECK constraints (which includes any NOT NULL constraint) are checked at the wrong time, or at least with the wrong data. The check should occur AFTER defaults and column affinity is applied before the data record is stored, meaning that

Re: [sqlite] Generated columns and COLLATE in the AS parens

2020-01-31 Thread Richard Hipp
On 1/31/20, Markus Winand wrote: > > - Expressions also have a declared type. More elaborate: the result value of > an expression has a type that is statically determined (again the “declared > type”). SQLite is a generalization of "Standard SQL" that allows expressions that can have an

Re: [sqlite] Generated columns and COLLATE in the AS parens

2020-01-31 Thread Keith Medcalf
If the standard requires static typing then anything it says about static types does not apply to SQLite3 because SQLite3 uses dynamic strong typing and does not use static fixed typing. That means that the "type" assigned in a column is merely a "suggestion" on how to store the data for this

Re: [sqlite] log() in sqlite3

2020-01-31 Thread Chris Brody
The log function does seem to be supported by extension-functions.c which is available from here: https://www.sqlite.org/contrib On Fri, Jan 31, 2020 at 1:30 PM David Raymond wrote: > The core functions of the library are fairly unlikely to get expanded upon > at this point, so it's up to the

Re: [sqlite] Compile error with SQLITE_OMIT_CTE (3.28)

2020-01-31 Thread Jens Alfke
> On Jan 31, 2020, at 9:55 AM, Jens Alfke wrote: > > If I define SQLITE_OMIT_CTE and compile the amalgamation (3.28.0), the build > fails due to two remaining calls to > sqlite3WithAdd() in the parser. This function is neither declared nor > implemented when SQLITE_OMIT_CTE is defined.

Re: [sqlite] log() in sqlite3

2020-01-31 Thread David Raymond
The core functions of the library are fairly unlikely to get expanded upon at this point, so it's up to the application using the SQLite library to expand on them. You can load an extension which has those functions. Or the C API gives you means to add your own functions. For Python, the

[sqlite] Compile error with SQLITE_OMIT_CTE (3.28)

2020-01-31 Thread Jens Alfke
If I define SQLITE_OMIT_CTE and compile the amalgamation (3.28.0), the build fails due to two remaining calls to sqlite3WithAdd() in the parser. This function is neither declared nor implemented when SQLITE_OMIT_CTE is defined. case 286: /* wqlist ::= nm eidlist_opt AS LP select RP */ {

[sqlite] log() in sqlite3

2020-01-31 Thread Peng Yu
Hi, I see that many math functions (like log()) are not in sqlite3. It seems that SQL standard doesn't have them. https://www.sqlite.org/lang_corefunc.html But since sqlite3 contains non-standard functions anyway. Would it be considered to add those functions? Given the current version of

Re: [sqlite] Is there a way to yield an error when opening a nonexistent dbfile?

2020-01-31 Thread Kees Nuyt
On Fri, 31 Jan 2020 09:02:10 -0600, Peng wrote: > Hi, > > By default the command sqlite3 will just open a dbfile if it does not exist. > > Suppose that I just want to perform read-only operations in a sqlite3 > session, I will not need to create a non-exsitent file. Rather, I want > the sqlite3

[sqlite] Is there a way to yield an error when opening a nonexistent dbfile?

2020-01-31 Thread Peng Yu
Hi, By default the command sqlite3 will just open a dbfile if it does not exist. Suppose that I just want to perform read-only operations in a sqlite3 session, I will not need to create a non-exsitent file. Rather, I want the sqlite3 to fail when the dbfile does not exist. Is there a way to

[sqlite] Import data from stdin to sqlite3 in python

2020-01-31 Thread Peng Yu
Hi, I see this post uses Pandas to import data to sqlite3. https://datatofish.com/create-database-python-using-sqlite3/ But I don't want to make my code depend on Pandas. I'd like to use something like ".import /dev/stdin" to directly import data from stdin in python. Is it possible? Thanks.

Re: [sqlite] Default isolation_level for sqlite3.connect?

2020-01-31 Thread David Raymond
> Is there a complete list that defines what are "the statements that > modify the database"? What is the difference between "the statements > that modify the database" and "Data Modification Language (DML) > statement"? Are they the same? If you dig into their code you can attempt to find what

Re: [sqlite] conditional insert operations

2020-01-31 Thread David Raymond
"What is v?" That's the name you gave your third field in your example > Suppose the table is this (the first line is just header) > > h1,h2,v /* Ensure there is an actual explicitly defined unique constraint on h1, h2 */ create unique index tbl_uidx_h1_h2 on tbl (h1, h2); /* Attempt to insert

Re: [sqlite] Default isolation_level for sqlite3.connect?

2020-01-31 Thread Peng Yu
The following is still very confusing. https://docs.python.org/3.8/library/sqlite3.html#controlling-transactions """ autocommit mode means that statements that modify the database take effect immediately." ... The Python sqlite3 module by default issues a BEGIN statement implicitly before a

Re: [sqlite] Is Comment column in 'EXPLAIN' blank?

2020-01-31 Thread x
Thanks David, getting them now. From: sqlite-users on behalf of David Raymond Sent: Friday, January 31, 2020 1:45:41 PM To: SQLite mailing list Subject: Re: [sqlite] Is Comment column in 'EXPLAIN' blank? To get the comments the library needs to have been

Re: [sqlite] Is Comment column in 'EXPLAIN' blank?

2020-01-31 Thread David Raymond
To get the comments the library needs to have been compiled with SQLITE_ENABLE_EXPLAIN_COMMENTS flag https://www.sqlite.org/compile.html#_options_to_enable_features_normally_turned_off That setting is off by default, but for the pre-compiled CLI they do include it. I'm not seeing it in the list

[sqlite] Is Comment column in 'EXPLAIN' blank?

2020-01-31 Thread x
I get the comments using the shell but running an explain query in c++ using sqlite3.c (from 3.30 amalgamation) column 7 is returning blank in every row. Is something up or is it my code? ___ sqlite-users mailing list

Re: [sqlite] Generated columns and COLLATE in the AS parens

2020-01-31 Thread Markus Winand
Let me first explain how collations work in standard SQL. I think my answers below make more sense then. In the SQL standard…. - character string **types** have properties such as fix-length vs. variable length, the length (limit), character set and also the collation. - columns have types,

Re: [sqlite] Default isolation_level for sqlite3.connect?

2020-01-31 Thread Graham Holden
Friday, January 31, 2020, 1:14:26 AM, Peng Yu wrote: > I still have a hard time to understand what the difference is > according to the python manual. It keeps saying see somewhere else in > the python manual. But I don't see where it explains the differences > between the differences