Sqlite3, inserting values in database

i have a small form of textfields and i need to add these informations
to a table in sqlite3 database. but i dont know how to do it. i mean
that its small address book program. and ‘id’ from ‘clients’ table has
to increments. i open database with : db = Database.open(“data.db”), but
then i dont know what to do…

anyone can help?

Well, if you create your table with the id set as an INTEGER PRIMARY
then it will auto-increment for you. You won’t need to do it yourself.
you have to do is insert the data. An example would be:

db.execute(“INSERT INTO clients (name,address,phone,email,website)

@name, @address, @phone, @email and @website would be TextCtrl’s that
the data that the user inputed. Then to get them back, you simply do:
db.execute(“SELECT * FROM clients;”) Which returns all rows in the
Or you can narrow down the entries, by doing db.execute(“SELECT * FROM
clients WHERE name=‘Mario S.’;”) Which will return any matches
the name column of the row has “Mario S.”

thanks a lot mario. so much.

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