#!/usr/bin/ruby# require's for the librets and mysql librariesrequire 'librets'require 'mysql'require 'pp'include Librets# Empty value for "values". I can into a problem with line 55 which required me toput this in.values = ""mls_number = ""# Initilizes and connects to the MySQL Databasemysql = Mysql.init()mysql.connect(host='<<database location>>', user='<<db user>>', passwd='<<dbpassword>>')mysql.select_db('Duluth')# Optional: I was going off another Ruby::DBI set of instructions. Only include ifyou want to start from fresh each time.mysql.query("ALTER TABLE residentialpropertyphotos DROP FOREIGN KEYresidentialpropertyphotos_ibfk_1;")mysql.query("DROP TABLE IF EXISTS ResidentialProperty")mysql.query("DROP TABLE IF EXISTS ResidentialPropertyPhotos")#Creates the Database to work with. I pulled the metadata from the RETS feed todetermine what the field types and lengths aremysql.query("CREATE TABLE ResidentialProperty (L_ListingID INT UNSIGNED NOT NULL,PRIMARY KEY (L_ListingID),L_AskingPrice INT NOT NULL, L_Keyword2 INT NOT NULL, L_Keyword3 INTNOT NULL, L_Keyword4 INT, L_City CHAR(50) NOT NULL, L_Area varchar(50) NOT NULL,L_AddressNumber varchar(15) NOT NULL, L_AddressDirection varchar(2),L_AddressStreet varchar(50) NOT NULL, LR_Remarks11 varchar(1000),LA1_UserFirstName varchar(15) NOT NULL, LO1_OrganizationNamevarchar(50) NOT NULL, LO1_PhoneNumber1Area INT,LO1_PhoneNumber1 INT) Type=INNODB;") mysql.query("CREATE TABLE ResidentialPropertyPhotos (PhotoID INT UNSIGNED NOT NULLAUTO_INCREMENT, PRIMARY KEY (PhotoID),L_ListingID INT UNSIGNED NOT NULL, Photo_Number varchar(5) NOT NULL,Photo LONGBLOB,INDEX (L_ListingID), FOREIGN KEY (L_ListingID) REFERENCESResidentialProperty (L_ListingID)) TYPE=INNODB;")# Creates a RETS Sessionsession = RetsSession.new("<<RETS URL>>")# Changes the encodeing from ASCII to ISOsession.set_default_encoding(RETS_XML_ISO_ENCODING)# Login into RETSif !session.login("<<RETS user>>", "<<RETS password>>")puts "Invalid login"exit 1end
Leave a Comment