What is Ruby SQLite GUI?
Ruby SQLite GUI is a simple, cross platform SQLite database administration tool written in Ruby using the Ruby/GTK2 bindings for Gtk+ and ActiveRecord as the back-end. It is targeted towards Rails developers using SQLite instead of the larger mySQL, pgSQL, etc. databases, but can be used for anything else in general.
Ruby SQLite GUI allows easy creation and administration of SQLite databases.
- Ruby 1.8.2 or higher.
- Ruby-GTK2 (gtk2 and libglade2) 0.13 or higher. (Windows users can view the install guide here.)
- Ruby/SQLite bindings (2 or 3 works).
- ActiveRecord (1.13.2 or higher).
- Download Ruby SQLite GUI
(If you'd like the latest version, possibly unstable, you can get it from the SVN Repository.)
- Untar/unzip the files to a directory that will not be deleted
- cd into the directory created (rsqlitegui_x.x)
- [Windows only] Skip the following step. You're done, but can create shortcuts as you wish. Ruby SQLite GUI must still be run from the command line/prompt though.
- One of the following:
- (As root)
./install.rbto install the rsqlitegui executable script that links to the current directory in /usr/local/bin
./install.rb --prefix=[other_dir]to install the rsqlitegui executable script in a desired directory
- Nothing! You can just call rsqlitegui by its absolute or relative path
- (As root)
Operations on the database are not like operations on a text file. Changes are immediate and saved to the database as soon as an action is performed. Most importantly, there is NO undo function. So be careful. The save button is only for saving a database as another one [in a different location], not for saving changes like in a text file.
Also, having an id (or other primary key) column is very important to ActiveRecord. By default when creating a table in the GUI, a primary key is created for you if you haven't specified one, but if you are performing your own raw SQL queries for creating custom tables, forgetting a primary key could cause unexpected problems. The same goes for editing existing databases without primary keys.
To open a SQLite database database.db, type in the console:
rsqlitegui [options] [database.db](Windows users will use the appropriate shortcut or file name for rsqlitegui.)
Command Line Options
rsqlitegui [options] [database]
Uses the sqlite2 store instead of sqlite3
To the left is the tables view. All the tables in the current database are here. Buttons for adding, removing, or renaming tables are below the view. Selecting a table from the tables view shows that table's contents in the larger table rows view.
Adding a Table
Enter in the new table name at the prompt (it can be changed later if you wish). You will be presented with the table creation window. Options at the top left are for columns you are adding. Options at the bottom right are specific for the table you are creating. The main view is of the columns that will be added to the new table. Columns can be rearranged in the view, so worrying about order is not necessary.
Removing or Renaming Tables
Self-explanitory. Select the appropriate button to perform the desired action.
Adding Rows to a Table
Back in the main window, select the table from the left-hand view you wish to add a row to. Then at the top, select the "Add Row" button. A set of fields is displayed for you to fill in.
Removing or Editing Rows in a Table
Self-explanitory. First, select the desired row in the view, and then select the appropriate button to perform the desired action.
Copying and Pasting rows in a Table
Self-explanitory. A selected row is required for copy. Pasting creates a new row with identical column values except the primary_key value.
Executing raw SQL
The button on the far right brings up a dialog for you to execute raw SQL. Keep in mind that you should create a primary key column if you are creating a custom table.
For your convenience, shortcuts are also placed in tooltips.
- Ctrl+N = Create new database
- Ctrl+O = Open database
- Ctrl+Shift+S = Save current database as...
- Ctrl+A = Add new row to table
- Ctrl+D = Delete current row from table
- Ctrl+E = Edit current row in table
- Ctrl+C = Copy current row in table
- Ctrl+V = Paste copied row as a new row in current table
- Ctrl+X = Execute raw SQL
- Ctrl+Shift+A = Add new table
- Ctrl+Shift+D = Delete current table
- Ctrl+Shift+R = Rename current table
- Ctrl+T = Focus to the tables view
- Ctrl+V = Focus to the table rows view
Add Table View
- Ctrl+A = Apply table changes
- Ctrl+C = Cancel table changes
- Ctrl+E = Edit selected column
- Ctrl+D = Delete selected column
- Ctrl+O = Add column to table
- Ctrl+V = Focus to the table columns view