Here are some database snippets which helped me when using a database connection for a mobile app I’m currently building.

Open a database connection:

var db = Titanium.Database.open('myDatabase');

Insert statement:

db.execute('INSERT INTO tablename (column1, column2) VALUES(?,?)', 1, 'One');
db.execute('INSERT INTO tablename (column1, column2) VALUES(?,?)', 2, 'Two');

Select statement:

var rows = db.execute('SELECT * FROM tablename');

Row count & resultset:

Titanium.API.info('Row count = ' + rows.getRowCount());
while (rows.isValidRow()){
	Titanium.API.info('column1: ' + rows.field(0) + ' column2: ' + rows.fieldByName('column2'));
	rows.next();
}
rows.close();

Update statement:

db.execute('UPDATE tablename SET column2 = "Three" WHERE column1 = 1');

Delete statement:

db.execute('DELETE FROM tablename WHERE column2 = "Two"');

Rows affected:

Titanium.API.info('Just inserted ' + db.rowsAffected + ' rows');

Last inserted row id

Titanium.API.info('Last inserted row id = ' + db.lastInsertRowId);

Close the database connection

db.close();

More database helpful guides:
[ Working with a SQLite Database | How to create and install a pre-populated database ]