:taxi: A simple tool for checking PostgreSQL Database in development mode (Quick check database without use rails console), life too short so make it easy
Just run command gem install huqua
or add gem 'huqua'
to Gemfile
Requitment:
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)
table_name
(table name NOT model name)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}
n
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
2: You can access the database from the terminal.
rails c
Cat.first
to see the first record.exit
to back terminal.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
. 😐