On 22/03/2011, at 9:04 AM, Erich93063 wrote:
> I am trying to create a SQLite database if it doesn't exist, which I
> know I can use 'CREATE TABLE IF NOT EXISTS", but more importantly, I
> need to initially populate the database with seed data if it doesn't
> exist. If I use CREATE TABLE IF NOT
On 11-03-22 10:40 AM, Simon Slavin wrote:
>
> Or just do a 'SELECT id FROM whatever LIMIT 1'. If you get any error, it
> doesn't exist, so create it and fill it.
>
> Or look in sqlite_master for an entry for the TABLE.
>
> Simon.
Could also use INSERT OR IGNORE statements for the seed data if
On 22 Mar 2011, at 1:38pm, Pavel Ivanov wrote:
> You can use a simple CREATE TABLE (without IF NOT EXISTS clause). If
> it succeeds then you populate table with data (remember to do that in
> the same transaction where you created the table). If CREATE TABLE
> fails then you don't insert your
Quoth Philip Graham Willoughby , on
2011-03-22 10:18:08 +:
> Yes, I had this problem - if sqlite3_open_v2 had an equivalent to
> O_EXCL it would make this a lot easier: you would only try to run
> your schema/prepopulating SQL if the exclusive open worked.
You can use a simple CREATE TABLE (without IF NOT EXISTS clause). If
it succeeds then you populate table with data (remember to do that in
the same transaction where you created the table). If CREATE TABLE
fails then you don't insert your data.
Pavel
On Mon, Mar 21, 2011 at 6:04 PM, Erich93063
On Tue, Mar 22, 2011 at 1:04 AM, Erich93063 wrote:
> I am trying to create a SQLite database if it doesn't exist, which I
> know I can use 'CREATE TABLE IF NOT EXISTS", but more importantly, I
> need to initially populate the database with seed data if it doesn't
> exist.
On 21 Mar 2011, at 22:04, Erich93063 wrote:
> I am trying to create a SQLite database if it doesn't exist, which I
> know I can use 'CREATE TABLE IF NOT EXISTS", but more importantly, I
> need to initially populate the database with seed data if it doesn't
> exist. If I use CREATE TABLE IF NOT
I am trying to create a SQLite database if it doesn't exist, which I
know I can use 'CREATE TABLE IF NOT EXISTS", but more importantly, I
need to initially populate the database with seed data if it doesn't
exist. If I use CREATE TABLE IF NOT EXISTS, it will obviously create
the table if it
8 matches
Mail list logo