daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyodbc
  2.  
  3. # creating a new db to load Iris sample in
  4. new_db_name = "MLRemoteExec"
  5. connection_string = "Driver=SQL Server;Server=localhost\MSSQLSERVER2017;Database={0};Trusted_Connection=Yes;"
  6.                         # you can also swap Trusted_Connection for UID={your username};PWD={your password}
  7. cnxn = pyodbc.connect(connection_string.format("master"), autocommit=True)
  8. cnxn.cursor().execute("IF EXISTS(SELECT * FROM sys.databases WHERE [name] = '{0}') DROP DATABASE {0}".format(new_db_name))
  9. cnxn.cursor().execute("CREATE DATABASE " + new_db_name)
  10. cnxn.close()
  11.  
  12. print("Database created")
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