php-sqlsrv/test/setup/cleanup_dbs.py
ulvii 41af6fc0a2 Database setup (#367)
* porting database setup files for functional tests

* Updating yml files to setup test databases before running the tests

* update spacing

* Renaming env variables

* Modifying cleanup_dbs.py and setup_dbs.py scripts so that they can execute database setup files

* update env variables

* Fix typo

* Update .travis.yml

* update env variables

* update travis scripts

* Checking sqlcmd setup on travis

* Checking sqlcmd setup on travis

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* sqlcmd bcp fix

* Adding a test to make sure the database is setup properly

* update exec_sql_scripts.py

* update sqlsrv_num_fields.phpt

* update sqlsrv_num_fields.phpt

* update

* Fixing identation
2017-05-01 11:20:53 -07:00

30 lines
1.1 KiB
Python

#!/usr/bin/env python
# py cleanup_dbs.py -dbname <DBNAME>
import os
import sys
import subprocess
import platform
import argparse
from subprocess import Popen, PIPE
from exec_sql_scripts import *
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-dbname', '--DBNAME', required=True)
args = parser.parse_args()
try:
server = os.environ['TEST_PHP_SQL_SERVER']
uid = os.environ['TEST_PHP_SQL_UID']
pwd = os.environ['TEST_PHP_SQL_PWD']
except :
print("TEST_PHP_SQL_SERVER environment variable must be set to the name of the server to use")
print("TEST_PHP_SQL_UID environment variable must be set to the name of the user to authenticate with")
print("TEST_PHP_SQL_PWD environment variable must be set to the password of the use to authenticate with")
sys.exit(1)
conn_options = ' -S ' + server + ' -U ' + uid + ' -P ' + pwd + ' '
executeSQLscript( os.path.join( os.path.dirname(os.path.realpath(__file__)), 'drop_db.sql'), conn_options, args.DBNAME)