Newbie - how to use SQLite3?

I am just learning Ruby language. I downloaded SQLite3 database using
gem - “gem list” shows that SQLite3 is installed.
My question - how to create a database? I tried to do it from a DOS
prompt - it didn’t work.

Thanks,

Zalek

On Thu, Jun 24, 2010 at 2:35 PM, [email protected] wrote:

I am just learning Ruby language. I downloaded SQLite3 database using
gem - “gem list” shows that SQLite3 is installed.

No, that shows that the SQLite3 gem is installed. Which doesn’t
mean you have SQLite3 itself on your system. Figuring that out is
a good first step :slight_smile:

My question - how to create a database? I tried to do it from a DOS
prompt - it didn’t work.

Urk, “DOS prompt”? So, Windows? Best of luck!

(And for the next question, “it didn’t work” is not terribly useful in
terms
of helping someone troubleshoot a problem…)

HTH,

On Thu, 24 Jun 2010 17:51:55 -0500, Hassan S.
[email protected] wrote:

Urk, “DOS prompt”? So, Windows? Best of luck!

(And for the next question, “it didn’t work” is not terribly useful in terms
of helping someone troubleshoot a problem…)

HTH,

Well, I tried from DOS:
create database
gem create database

and other combinations.

Anyway - I understand I need to install SQLite3 first.

Thanks,

Zalek

On Jun 24, 11:14 pm, [email protected] wrote:

of helping someone troubleshoot a problem…)

  1. gem install sqlite3-ruby

Download and copy latest sqlite3.dll from sqlite3.org into a directory
in the PATH. If you’re not familiar with DOS command prompts, search
for tutorials on internet.

You have sqlite3-ruby documentation here:

http://rdoc.info/projects/luislavena/sqlite3-ruby

unknown wrote:

I am just learning Ruby language. I downloaded SQLite3 database using
gem - “gem list” shows that SQLite3 is installed.
My question - how to create a database? I tried to do it from a DOS
prompt - it didn’t work.

Thanks,

Zalek

require ‘sqlite3’
db = SQLite3::Database.new( “test.db” )
sql = <<SQL
create table the_table (
a varchar2(30),
b varchar2(30)
);

SQL

db.execute_batch( sql )


Of course, you should have sqlite3 installed. there should be some
command called “sqlite3” in your path, if it is.

to open a db, do:

sqlite3 new.db

You should get a prompt. Type “help”.

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