Method: Og::MysqlAdapter#initialize
- Defined in:
- lib/og/adapter/mysql.rb
#initialize(options) ⇒ MysqlAdapter
Initialize the MySQL store.
Options
-
:name, the name of the database.
-
:user, the username for using the database.
-
:password, the password of the database user.
-
:address, the addres where the server is listening.
-
:port, the port where the server is listening.
-
:socket, is useful when the pure ruby driver is used.
this is the location of mysql.sock. For Ubuntu/Debian this is '/var/run/mysqld/mysqld.sock'. You can find the location for your system in my.cnf
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/og/adapter/mysql.rb', line 52 def initialize() super @typemap.update(TrueClass => 'tinyint', Time => 'datetime') @conn = Mysql.connect( [:address] || [:host] || 'localhost', [:user], [:password], [:name], [:port], [:socket] ) # You should set recconect to true to avoid MySQL has # gone away errors. if @conn.respond_to? :reconnect [:reconnect] = true unless .has_key?(:reconnect) @conn.reconnect = [:reconnect] end rescue Object => ex if database_does_not_exist_exception? ex Logger.info "Database '#{[:name]}' not found!" create_db() retry end raise end |