CREATE TABLE ... doesn't work sometimes

with the following script :
#! /usr/bin/env ruby

begin; require ‘rubygems’; rescue LoadError; end

require ‘sqlite3’

db = SQLite3::Database.new( ‘ou-ou.db’ )

db.execute <<SQL
BEGIN TRANSACTION;
CREATE TABLE devicephonebook (
UID INTEGER PRIMARY KEY AUTOINCREMENT,
lastName TEXT NOT NULL DEFAULT(’’),
firstName TEXT NOT NULL DEFAULT(’’),
fullLastName TEXT
);
COMMIT;
SQL

if, from command line, i do :

$ sqlite3 ou-ou.db
[…]
sqlite> .dump devicephonebook I get :
BEGIN TRANSACTION;
COMMIT;
sqlite>

then, no table created, why ?

i wrote “sometimes” because i’ve the feeling that if i INSERT something
just afterwards creating the table it’s OK ???

Hi,

Ideally, to do transactions, you should use the db.transaction method;

http://sqlite-ruby.rubyforge.org/sqlite3/faq.html#538670536

HTH,

Arlen

Arlen Christian Mart C. [email protected] wrote:

Ideally, to do transactions, you should use the db.transaction method;

http://sqlite-ruby.rubyforge.org/sqlite3/faq.html#538670536

OK, fine thanks !

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs