Skip to content

Instantly share code, notes, and snippets.

@mockdeep
Created July 16, 2012 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mockdeep/3120713 to your computer and use it in GitHub Desktop.
Save mockdeep/3120713 to your computer and use it in GitHub Desktop.
Active Record example without Rails
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'database')
ActiveRecord::Base.connection.execute <<-SQL
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR
);
SQL
class User < ActiveRecord::Base
end
u = User.new
u.name = 'blah'
u.save
puts User.first.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment