def test_connection_error(self): """ Attempt an invalid connection and check the error for a password. """ from django.conf import settings databases = {} databases.update(settings.DATABASES['default']) databases['USER'] = '******' databases['PASSWORD'] = '******' connection_string = base.make_connection_string(databases) with self.assertRaises(dbapi.OperationalError) as err: dbapi.connect(connection_string) self.assertNotIn('PWD=myPass;', str(err.exception)) self.assertIn('PWD=******;', str(err.exception))
def main(): connection = db.connect("PROVIDER=SQLOLEDB;DATA SOURCE=localhost\\ss2005;Initial Catalog=Ted;Integrated Security=SSPI") sproc_2b(connection) connection.close()