Just run command gem install huqua
or add gem 'huqua'
to Gemfile
Requitment:
- platform: macOS/Linux
- database: PostgreSQL
Note
On Linux
, make sure you config database.yml like this:
development:
adapter: postgresql
host: localhost
encoding: unicode
database: your_database_name
pool: 5
username: your_username_in_database
password: your_password
Run huqua
Result like:
Congrats, you have good connection to database !
You have 5 tables in your database:
- admins (2)
- comic_photo_ens (0)
- comic_photos (0)
- comics (6)
- infomations (0)
Run huqua table_name
Ex: huqua users
Result like:
Congrats, you have good connection to database !
The first record:{"id"=>"1", "created_at"=>"2019-05-07 06:16:17.272652", "updated_at"=>"2019-05-07 06:16:17.272652", "email"=>"[email protected]", "encrypted_password"=>"$2a$11$PrsExR3x5HrqK5n3d/RCDeQNDbVKqRmdLsB58ZdBv/fV4x2hJU0OK", "reset_password_token"=>nil, "reset_password_sent_at"=>nil, "remember_created_at"=>nil}
Run huqua users n
Ex: huqua users 1
to return users have id = 1
Result like:
Congrats, you have good connection to database !
The first record:{"id"=>"1", "created_at"=>"2019-05-07 06:16:17.272652", "updated_at"=>"2019-05-07 06:16:17.272652", "email"=>"[email protected]", "encrypted_password"=>"$2a$11$PrsExR3x5HrqK5n3d/RCDeQNDbVKqRmdLsB58ZdBv/fV4x2hJU0OK", "reset_password_token"=>nil, "reset_password_sent_at"=>nil, "remember_created_at"=>nil}
Just run: gem uninstall huqua
and press enter
If you are a newbie in ruby on rails development, so many times, you can test your database on the local environment to make sure your connection to the database is successful or success to import data (from SQL or CSV...)
You have 2 choices.
1: You can open an administrator platform for PostgreSQL like pgadmin
- need to install a tool (not good for a weak computer).
- open the tool and checking (wasting time and not good for a weak computer again :D)
2: You can access the database from the terminal.
- step 1: type command
rails c
- step 2: try to remember the model name and typing like
Cat.first
to see the first record. - step 3: need to
exit
to back terminal. - do again when you need to check something or open a new terminal window. ...
So I think I can make it simple, when I need to check structure simple, like check new record can save in DB or check number records of a table.
So I build a simple tool. At this time, it work only with PostgreSQL
. 😐