Changeset 3759

Show
Ignore:
Timestamp:
07/17/08 11:44:28 (5 weeks ago)
Author:
travis
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/opus_core/database_management/database_server.py

    r3758 r3759  
    1818from sqlalchemy import create_engine 
    1919 
     20import os 
    2021 
    2122class DatabaseServer(object): 
     
    3738         
    3839        if self.protocol == 'mssql': 
    39             print str(database_server_configuration) 
    40             self.engine = create_engine(str(database_server_configuration)) 
    41  
    42         else: 
    43             self.engine = create_engine(self.get_connection_string()) 
    44          
    45          
     40            if 'MSSQLDEFAULTDB' not in os.environ: 
     41                raise 'To connect to a Microsoft SQL Server, a default database to connect to must be specified in the environment variables under MSSQLDEFAULTDB'  
     42        self.engine = create_engine(self.get_connection_string()) 
     43                 
    4644        self.metadata = MetaData( 
    4745            bind = self.engine 
     
    5553 
    5654    def get_connection_string(self): 
    57         return '%s://%s:%s@%s'%(self.protocol, self.user_name, self.password, self.host_name)  
    58      
     55        if self.protocol == 'mssql': 
     56            return '%s://%s:%s@%s'%(self.protocol, self.user_name, self.password, self.host_name)  
     57        else: 
     58            return '%s://%s:%s@%s/%s'%(self.protocol, self.user_name, self.password, self.host_name, os.environ['MSSQLDEFAULTDB'])  
     59 
    5960    def log_sql(self, sql_query, show_output=False): 
    6061        if show_output == True: