Class: FireRuby::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/src.rb

Overview

This class represents an existing database that can be connected to. It also provides functionality to allow for the creation of new databases.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, set = nil) ⇒ Database

This is the constructor for the Database class.

Parameters

file

A string containing the database file specifier. This can include details for a remote server if needed.

set

A string containing the name of the character set to be used with the database. Defaults to nil.



71
72
# File 'lib/src.rb', line 71

def initialize(file, set=nil)
end

Class Method Details

.create(file, user, password, size = 1024, set = nil) ⇒ Object

This method can be used to programmatically created a database file. If successful this method returns a Database object.

Parameters

file

A string containing the path and name of the database file to be created.

user

A string containing the user name that will be used in creating the file.

password

A string containing the user password that will be used in creating the file.

size

The page size setting to be used with the new database file. This should be 1024, 2048, 4096 or 8192. Defaults to 1024.

set

The name of the default character set to be assigned to the new database file. If this parameter is specifed then the Database object created by the call will use it to whenever a connection request is made. Defaults to nil.

Exceptions

Exception

Generated whenever an invalid parameter is specified or a problem occurs creating the database file.



147
148
# File 'lib/src.rb', line 147

def Database.create(file, user, password, size=1024, set=nil)
end

Instance Method Details

#character_setObject

This method fetches the name of the character set currently assigned to a Database object. This can return nil to indicate that a explicit character set has not been assigned.



156
157
# File 'lib/src.rb', line 156

def character_set
end

#character_set=(set) ⇒ Object

This method allows the specification of a database character set that will be used when creating connections to a database. The value set by this method can be overridden by providing an alternative in the connect call. To remove a character set specification from a Database object pass nil to this method.

Parameters

set

A string containing the name of the database character set.



170
171
# File 'lib/src.rb', line 170

def character_set=(set)
end

#connect(user = nil, password = nil, options = nil) {|connection| ... } ⇒ Object

This method attempts to establish a connection to a database. If successful then a Connection instance is returned. If a block is provided to the method then the connection is closed after the block completes. If a block is specified the connection is provided as a parameter to the block.

Parameters

user

The user name to be used in making the connection. This defaults to nil.

password

The password to be used in making the connection. This defaults to nil.

options

A Hash of connection options. This should be made up of key/setting pairs where the keys are from the list that is defined within the Connection class. The settings are particular to the key, see the documentation for the Connection class for more details.

Exceptions

Exception

Thrown whenever a problem occurs connecting with the database.

Yields:

  • (connection)


104
105
106
# File 'lib/src.rb', line 104

def connect(user=nil, password=nil, options=nil)
   yield(connection)
end

#drop(user, password) ⇒ Object

This method attempts to drop the database referred to by the details in a Database object.

Parameters

user

The user name to be used in dropping the database.

password

The password to be used in dropping the database.

Exceptions

FireRubyError

Thrown whenever a problem occurs dropping the database instance.



121
122
# File 'lib/src.rb', line 121

def drop(user, password)
end

#fileObject

This is the accessor for the database file specification attribute.



78
79
# File 'lib/src.rb', line 78

def file
end