ruby mysql blob

Recently, one of mycert’s internal project required that PDF files to be saved into the database (MyQL). Since its is not easy to find the sample code via Google,  here’s a quick note for future reference. fContent = File.open(“/path/file”, “wb”).read() db = Mysql.new(‘localhost’, ‘user’, ‘password’, ‘database’) st = db.prepare(“insert into tableA( fieldBlob) values (?)”) st.execute(fContent) […]