d968e17823
1. Added a method to ask for the default mode (TUI, GUI, or WebApp) during the first run setup. 2. Implemented a method to validate the input mode. 3. Improved the database connection test method to handle exceptions and return a boolean value. 4. Added a method to ask for database details (username, password, and database name). 5. Enhanced the user interface by adding Curses.clear before each question to make the interface cleaner. 6. Improved the password input process by disabling echo to hide the input from the screen. 7. Added validation for uplink and downlink speeds. 8. Added a method to ask for services the system should be aware of.
20 lines
511 B
Ruby
20 lines
511 B
Ruby
class DatabaseManager
|
|
def initialize
|
|
@db = nil
|
|
end
|
|
|
|
def test_db_connection(db_details)
|
|
begin
|
|
connection_string = "mysql2://#{db_details[:username]}:#{db_details[:password]}@localhost/#{db_details[:database]}"
|
|
@db = Sequel.connect(connection_string)
|
|
# Try a simple query to test the connection
|
|
@db.run "SELECT 1"
|
|
true
|
|
rescue Sequel::DatabaseConnectionError
|
|
false
|
|
ensure
|
|
@db.disconnect if @db
|
|
end
|
|
end
|
|
end
|
|
|