daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env ruby
  2.  
  3. require 'mysql2'
  4. require 'ap'
  5.  
  6. client = Mysql2::Client.new(
  7.   :username => 'injekt',
  8.   :password => 'foo',
  9.   :database => 'test_one'
  10. )
  11.  
  12. queries = DATA.read.split("\n\n")
  13.  
  14. queries.each do |query|
  15.   client.query query
  16. end
  17.  
  18. client.query("SELECT *, INET_NTOA(`addr`) AS `ip` FROM `users` LIMIT 1").each do |user|
  19.   ap user
  20. end
  21.  
  22. __END__
  23. DROP TABLE IF EXISTS `users`;
  24.  
  25. CREATE TABLE `users` (
  26.   `id`          INT NOT NULL AUTO_INCREMENT,
  27.   `name`        VARCHAR(15) NOT NULL,
  28.   `password`    VARCHAR(32) NOT NULL,
  29.   `addr`        INT(10) NOT NULL,
  30.   PRIMARY KEY (`id`)
  31. );
  32.  
  33. INSERT INTO `users`
  34.   (`name`, `password`, `addr`)
  35. VALUES  
  36.   ('injekt', md5('bar'), INET_ATON('127.0.0.1'));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top