Skip to content

Instantly share code, notes, and snippets.

@metaskills
Last active February 22, 2017 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/0cb3345be80c3915ba6b08f417f40cd8 to your computer and use it in GitHub Desktop.
Save metaskills/0cb3345be80c3915ba6b08f417f40cd8 to your computer and use it in GitHub Desktop.
require 'tiny_tds'
puts 'Connecting to SQL Server'
@client = TinyTds::Client.new(
host: 'localhost', port: 1433,
username: 'sa', password: ENV['SA_PASSWORD'],
)
def execute(sql)
@client.execute(sql).do
true
end
puts 'Creating Database'
execute "CREATE DATABASE SampleDB"
@client.close
puts 'Done'
# Output
Connecting to SQL Server
Creating Database
Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment