Re: [sqlite] Add Column with "If Not Exists"

2018-08-02 Thread Richard Hipp
On 8/1/18, Charles Leifer wrote: > You can simply use: > > PRAGMA table_info('my_table') > > To get a list of columns, which you can check against and then > conditionally add your column. From C-code, you can use the sqlite_table_column_metadata() interface [1] to quickly check for the

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Warren Young
On Aug 1, 2018, at 3:57 PM, Tim Streater wrote: > > On Aug 1, 2018, at 1:52 PM, Tim Streater wrote: >>> >>> I don't use the pragma since, officially, they are unsupported. >> > Specific pragma statements may be removed and others added in future releases > of SQLite. There is no guarantee of

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Tim Streater
On 01 Aug 2018, at 21:06, Warren Young wrote: > On Aug 1, 2018, at 1:52 PM, Tim Streater wrote: >> >> I don't use the pragma since, officially, they are unsupported. > > “Unsupported” how? It’s documented and part of the SQLite file header, which > is quite stable. > > If you mean this is not

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Warren Young
On Aug 1, 2018, at 1:52 PM, Tim Streater wrote: > > I don't use the pragma since, officially, they are unsupported. “Unsupported” how? It’s documented and part of the SQLite file header, which is quite stable. If you mean this is not standard SQL and thus doesn’t work on non-SQLite DBs,

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Tim Streater
On 01 Aug 2018, at 20:40, Warren Young wrote: > On Aug 1, 2018, at 7:34 AM, Simon White > wrote: >> >> I would like to suggest the addition of the "If not exists" to the Add >> Column feature of SQLite. > > I maintain an application that’s been thr

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Warren Young
On Aug 1, 2018, at 7:34 AM, Simon White wrote: > > I would like to suggest the addition of the "If not exists" to the Add Column > feature of SQLite. I maintain an application that’s been through dozens of schema changes over its nearly quarter century of life, so let me

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Don V Nielsen
This makes me feel there is a lot of pain coming in the future. Given an update statement for n dbs of unknown state, When a db lacks columns necessary to successfully execute the sql Then add the columns to the db I'm trying to imagine how to keep n remote dbs in a known state, say z, when

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread R Smith
On 2018/08/01 5:29 PM, Charles Leifer wrote: You can simply use: PRAGMA table_info('my_table') To get a list of columns, which you can check against and then conditionally add your column. Aye, but during a script in SQL-only you don't have that luxury. One could also use a similar pragma

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Charles Leifer
st the addition of the "If not exists" to the Add > > Column feature of SQLite. There are quite common situations where > > ensuring a column exists is important so that an update to remote > > devices will not fail but it is not so important that deprecated fields > >

Re: [sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Tim Streater
On 01 Aug 2018, at 14:34, Simon White wrote: > I would like to suggest the addition of the "If not exists" to the Add > Column feature of SQLite.  There are quite common situations where > ensuring a column exists is important so that an update to remote >

[sqlite] Add Column with "If Not Exists"

2018-08-01 Thread Simon White
Hi I would like to suggest the addition of the "If not exists" to the Add Column feature of SQLite.  There are quite common situations where ensuring a column exists is important so that an update to remote devices will not fail but it is not so important that deprecated fields