Ruby/ActiveRecord/Table Name
Материал из Wiki.crossplatform.ru
Содержание |
Connection string for Oracle
ActiveRecord::Base.establish_connection( :adapter => "oracle", :database => "test", :username => "kevin", :password => "test")
Indicate table name in ActiveRecord
=begin create database Contact; use Contact; CREATE TABLE Employee ( Name VARCHAR(50), Phone VARCHAR(15) ); =end require "rubygems" require "activerecord" ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "localhost", :username => "root", :database => "Contact") class Employee < ActiveRecord::Base set_table_name "employee" end account = Employee.new account.Name = "AAA" account.save
PostgreSQL Connection Parameters
ActiveRecord::Base.establish_connection( :adapter => "postgresql", :database => "test", :username => "kevin", :password => "test")
SQLite Parameters
ActiveRecord::Base.establish_connection( :adapter => "sqlite", :database => "test")
SQL Server Parameters
ActiveRecord::Base.establish_connection( :adapter => "sqlserver", :database => "test", :username => "kevin", :password => "test", :host => "www.yourdbserver.ru")
Sybase Parameters
The following example shows how to open an Active Record database connection for Sybase: ActiveRecord::Base.establish_connection( :adapter => "sybase", :database => "test", :host => "www.yourdbserver.ru", :usrname => "kevin", :password => "test")