First part of the project, you will need to install ruby, postgreSQL, and the postgres ruby gem. Everything for this project is being developed under Windows. If you are using an operating system other than windows, you may have to make changes that are different from my documentation.
Download and install the latest version of Ruby from the Ruby Site here
Download and install the latest version of PostgresSQL here
When installing change the default port to 5230
Bring up a command prompt and install the ruby gem postgres
gem install postgres
This is optional, but you can download and install
pgAdmin, pgAdmin is a database administration tool for Postgres.
SciTE is installed with Ruby, you will want to launch this and place the following code into it. Save the code to a file like test_db.rb. Then press f5 to execute the script. You’ll need to key in your password that you created while installing postgres.
require 'postgres'
conn = PGconn.connect("127.0.0.1", 5430, "", "", "postgres","postgres","[password]")
sql = "select * from pg_tablespace"
res_pid = conn.query(sql )
res_pid.each do |x|
p x
end
If everything has been done correctly you should get a result like this:
>ruby db_check.rb
["pg_default", "10", "", nil]
["pg_global", "10", "", nil]
>Exit code: 0
If not you’ll have to look at the error messages that generated instead to figure out what is wrong with the setup. Once complete you’ll be able to go to the next Step.
Labels: Ruby, Stock
0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home