Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread
Message: 48787
BY: Rakesh Ramakrishnan (rakesh)
DATE: 2008-03-10 15:11
SUBJECT: FreeTDS + Ruby DBI + MS Sql

 

hi all,

I am using Ruby DBI + FreeTDS + MS Sql Server 2005 for my development. I was successful in making a connection to the database and execute different database operations. But I have problems in retrieving the metadata about columns in a table. I am trying to retrieve the primary keys of a table but I am not able to do so. I have pasted the sample code below which fails

DBI.connect('dbi:ODBC:tosqlserver', 'xyz', 'abcde') do | dbh |


sth = dbh.execute('select * from DataPreprocess')
rows = sth.fetch_all
puts sth.methods

sth.column_info.each_with_index do |info,i|
printf "primary: %s\n",info["primary"]
end
sth.finish

end

Could u please suggest a solution or an alternate way to retrieve the primary keys of the table ?


Thread View

Thread Author Date
FreeTDS + Ruby DBI + MS SqlRakesh Ramakrishnan2008-03-10 15:11
      RE: FreeTDS + Ruby DBI + MS SqlRoman Rozinov2009-02-11 07:01
      RE: FreeTDS + Ruby DBI + MS SqlErik Hollensbe2009-02-17 00:28
      RE: FreeTDS + Ruby DBI + MS SqlRoman Rozinov2009-03-03 06:44
            RE: FreeTDS + Ruby DBI + MS SqlErik Hollensbe2009-03-03 08:52
                  RE: FreeTDS + Ruby DBI + MS SqlRoman Rozinov2009-03-04 06:13

Post a followup to this message