[sqlite] What is the C language standard to which sqlite conforms ?

2019-11-15 Thread Dennis Clarke
This may have been asked many times before but always seems to be a valid question. On some machines with different compilers I get good results using C99 strict compliance. On other machines, such as those running Red Hat Enterprise Linux, I get terrible results. Also I am using a variety of

Re: [sqlite] BUG and WORKAROUND sqlite3 shell .parameter command evaluating arguments when it shouldn't.

2019-11-15 Thread Keith Medcalf
I think this is a bug. However, looking at the code the way to achieve that is to surround the string in double quotes which will cause exactly what appears between the double-quotes to be stored. I think it is because of the way the parsing and mprintf function works ... sqlite> .param

Re: [sqlite] Question about: Adding a record to a table with select failure

2019-11-15 Thread Simon Slavin
On 15 Nov 2019, at 9:04pm, Jose Isaias Cabrera wrote: > CASE > SELECT a from t WHERE a = 'p006' idate desc limit 1 >WHEN a = NULL >THEN 'p006',1,2,'y',4,'2019-02-12' >ELSE SELECT a, b, c, 'y', e, '2019-20-12' from t WHERE a = 'p006' idate > desc limit 1 >END The thing

Re: [sqlite] How to update plural rows from one table to another.

2019-11-15 Thread Keith Medcalf
On Friday, 15 November, 2019 15:22, Gan Uesli Starling wrote: >In the following update query, I had expected for the integer values >"rowid" from the table "info" to project copies of themselves singly and >separately into the integer cells "info_id" of table "qso", row-by-row, >where the

[sqlite] How to update plural rows from one table to another.

2019-11-15 Thread Gan Uesli Starling
In the following update query, I had expected for the integer values "rowid" from the table "info" to project copies of themselves singly and separately into the integer cells "info_id" of table "qso", row-by-row, where the timestamps "t_from" of each are matching. UPDATE qso SET info_id = (  

Re: [sqlite] mport SQLite import Latin1 data?

2019-11-15 Thread Richard Damon
On 11/15/19 4:45 PM, Winfried wrote: > It's odd that SQLite doesn't support this, since it's not uncommun to have > big Latin1 input files that can take a while to load in eg. Excel. > > For others' benefit, GNUWin32's iconv is very fast: > > "C:\Program Files\GnuWin32\bin\iconv.exe" -f

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Winfried
It's odd that SQLite doesn't support this, since it's not uncommun to have big Latin1 input files that can take a while to load in eg. Excel. For others' benefit, GNUWin32's iconv is very fast: "C:\Program Files\GnuWin32\bin\iconv.exe" -f "windows-1252" -t "UTF-8" "input.1252txt" >

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Warren Young
On Nov 15, 2019, at 2:15 PM, Jose Isaias Cabrera wrote: > > Shawn Wagner, on Friday, November 15, 2019 04:01 PM, wrote... >> >> If you're on Windows, which cp1252 suggests, just make sure that you don't >> end up with a BOM at the start of the file when you convert it. Windows >> tools that

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Shawn Wagner
Unlike UTF-16, which uses 2 byte code units without a fixed endianess (meaning to be robust you need to account for both little and big endian encodings when reading files using it), UTF-8 uses a 1 byte code unit and thus doesn't have any endian issues or a need for a byte order mark. On Fri, Nov

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Jose Isaias Cabrera
Shawn Wagner, on Friday, November 15, 2019 04:01 PM, wrote... > > If you're on Windows, which cp1252 suggests, just make sure that you don't > end up with a BOM at the start of the file when you convert it. Windows > tools that output utf-8 are sometimes prone to add one even though it's >

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Keith Medcalf, on Friday, November 15, 2019 03:50 PM, wrote... > > > How you would use bound parameters depends on what you are using to interface > with the sqlite3 database. > > https://www.sqlite.org/c3ref/bind_blob.html for the C interfaces. > > In something like python you would pass the

Re: [sqlite] Question about: Adding a record to a table with select failure

2019-11-15 Thread Jose Isaias Cabrera
Doug, on Friday, November 15, 2019 11:42 AM, wrote... > > WRT Jose's original context, and just for my enlightment, what happens with > the following: > > insert into t (a, b, c, d, e, idate) > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p999'; > > where p999 does not define a record?

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Shawn Wagner
If you're on Windows, which cp1252 suggests, just make sure that you don't end up with a BOM at the start of the file when you convert it. Windows tools that output utf-8 are sometimes prone to add one even though it's pointless to have. On Linux etc., you can try .import '| iconv -f cp1252 -t

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Keith Medcalf
How you would use bound parameters depends on what you are using to interface with the sqlite3 database. https://www.sqlite.org/c3ref/bind_blob.html for the C interfaces. In something like python you would pass the bindings as a tuple to the execute method of the cursor: cr.execute(sql,

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Jose Isaias Cabrera
Winfried, on Friday, November 15, 2019 03:13 PM, wrote... > > Hello, > > I have a big CSV file that's encoded in Latin1 (cp1252), while SQLite stores > strings as Unicode. > > Neither Google nor ".help" helped to find if SQLite offers a switch to > convert Latin1 to UTF-8 on the fly before

Re: [sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Tim Streater
On 15 Nov 2019, at 20:13, Winfried wrote: > I have a big CSV file that's encoded in Latin1 (cp1252), while SQLite stores > strings as Unicode. > > Neither Google nor ".help" helped to find if SQLite offers a switch to > convert Latin1 to UTF-8 on the fly before running the ".import" command. > >

Re: [sqlite] How to use CASE statement to SUM() some numbers

2019-11-15 Thread Jim Morris
Maybe something like: CREATE VIEW "Sum of Expenses Between two Dates" AS SELECT Date, sum( CASE WHEN Date BETWEEN date('now', '-1 months') AND date('2019-11-04', '-1 days') THEN Expense ELSE 0 END) as 'Sum of Expenses:' FROM Expenses; On 11/15/2019 12:22 PM, David

Re: [sqlite] How to use CASE statement to SUM() some numbers

2019-11-15 Thread David Raymond
So why do you need a case? What will not work with the simple: select sum(Expense) from Expenses where Date between date('now', '-1 months') and date('2019-11-04', '-1 days'); ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

[sqlite] Can SQLite import Latin1 data?

2019-11-15 Thread Winfried
Hello, I have a big CSV file that's encoded in Latin1 (cp1252), while SQLite stores strings as Unicode. Neither Google nor ".help" helped to find if SQLite offers a switch to convert Latin1 to UTF-8 on the fly before running the ".import" command. Should I first convert the file into UTF-8

[sqlite] How to use CASE statement to SUM() some numbers

2019-11-15 Thread Csanyi Pal
Hi, I have a simple database, the 'Incomes_Expenses.db' on my system. It's SQL is here: -- -- File generated with SQLiteStudio v3.2.1 on P nov. 15 20:39:18 2019 -- -- Text encoding used: UTF-8 -- PRAGMA foreign_keys = off; BEGIN TRANSACTION; -- Table: Expenses CREATE TABLE Expenses (Id

Re: [sqlite] Question about: Adding a record to a table with select failure

2019-11-15 Thread Jose Isaias Cabrera
Simon Slavin, on Friday, November 15, 2019 11:58 AM, wrote... > > On 15 Nov 2019, at 4:48pm, Jose Isaias Cabrera, on > > > It does not get inserted. > > The SELECT returns zero lines. Therefore zero lines get inserted. You might > like to try > one where the SELECT returns more than one line.

[sqlite] sqlite3 shell .parameter command evaluating arguments when it shouldn't.

2019-11-15 Thread Shawn Wagner
Consider: sqlite> .parameter init sqlite> .parameter set :date '2019-11-15' sqlite> .parameter list :date 1993 How do I make it treat the value argument as a string and not as a numeric expression that gets evaluated? ___ sqlite-users mailing list

Re: [sqlite] Question about: Adding a record to a table with select failure

2019-11-15 Thread Simon Slavin
On 15 Nov 2019, at 4:48pm, Jose Isaias Cabrera wrote: > It does not get inserted. The SELECT returns zero lines. Therefore zero lines get inserted. You might like to try one where the SELECT returns more than one line. ___ sqlite-users mailing list

Re: [sqlite] Question about: Adding a record to a table with select failure

2019-11-15 Thread Jose Isaias Cabrera
Doug, on Friday, November 15, 2019 11:42 AM, wrote... > > WRT Jose's original context, and just for my enlightment, what happens with > the following: > > insert into t (a, b, c, d, e, idate) > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p999'; > > where p999 does not define a record?

Re: [sqlite] Question about: Adding a record to a table with select failure

2019-11-15 Thread Doug
WRT Jose's original context, and just for my enlightment, what happens with the following: insert into t (a, b, c, d, e, idate) SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p999'; where p999 does not define a record? Is a new record inserted with values of a,b,c, and e null? >

Re: [sqlite] database disk image is malformed

2019-11-15 Thread Peter da Silva
I have been bitten by this a couple of times, so now I'm super-conservative about how I deal with this. What I do is have any parent database setup done by having the parent spawn a child process to do the actual database work, and return any data the parent needs in the status or (if more than a

Re: [sqlite] Relax "DISTINCT aggregates" error

2019-11-15 Thread Jose Isaias Cabrera
Dominique Devienne, on Friday, November 15, 2019 09:02 AM, wrote... > > As can be seen below, the last query fail, despite the one before it > succeeding. > Yet the second argument is constant, thus it would seem "natural" for it to > work as well. > Could the error be "relaxed", when the

[sqlite] Relax "DISTINCT aggregates" error

2019-11-15 Thread Dominique Devienne
As can be seen below, the last query fail, despite the one before it succeeding. Yet the second argument is constant, thus it would seem "natural" for it to work as well. Could the error be "relaxed", when the non-first argument(s) to aggregate functions are constant? Thanks, --DD

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Simon Slavin, on Thursday, November 14, 2019 06:48 PM, wrote... > > On 14 Nov 2019, at 10:27pm, Jake Thaw, on > > > Why not like this? > > > > insert into t (a, b, c, d, e, idate) > > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > > idate desc limit 1; > > Dammit. I

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Keith Medcalf, on Thursday, November 14, 2019 06:44 PM, wrote... > > > On Thursday, 14 November, 2019 15:27, Jake Thaw, on > > >Why not like this? > > >insert into t (a, b, c, d, e, idate) > >SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > >idate desc limit 1; > > Or, if

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Jake Thaw, on Thursday, November 14, 2019 05:27 PM, wrote... > > Why not like this? > > insert into t (a, b, c, d, e, idate) > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > idate desc limit 1; Thanks. Yes, this is great! Darn it, I didn't think of this. Thanks again.

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Simon Slavin, on Thursday, November 14, 2019 05:18 PM, wrote... > > On 14 Nov 2019, at 10:06pm, Jose Isaias Cabrera, on > > > insert into t (a, b, c, d, e, idate) values > > ( > >(SELECT a FROM t WHERE a = 'p001' ORDER BY idate desc limit 1), > >(SELECT b FROM t WHERE a = 'p001' ORDER BY

Re: [sqlite] database disk image is malformed

2019-11-15 Thread Rowan Worth
On Fri, 15 Nov 2019 at 16:10, Graham Holden wrote: > I've been having problems with my email system... I don't think > earlier attempts at sending have made it to the list, but if they > did, apologies for any duplication... > > Monday, November 11, 2019, 5:46:05 PM, Jukka Marin > wrote: > > >>

Re: [sqlite] database disk image is malformed

2019-11-15 Thread Simon Slavin
On 15 Nov 2019, at 8:03am, Graham Holden wrote: > What I *think* this may mean is that re-spawned children will inhereit > the open file-handle of the SQLite connection opened by the parent > after it initially fired all child processes. That's not a problem. > Even if the (re-spawned) > child

Re: [sqlite] database disk image is malformed

2019-11-15 Thread Graham Holden
I've been having problems with my email system... I don't think earlier attempts at sending have made it to the list, but if they did, apologies for any duplication... Monday, November 11, 2019, 5:46:05 PM, Jukka Marin wrote: >> On 11 Nov 2019, at 5:13pm, Jukka Marin wrote: >> >> > The main