Rosetta Utilities  2014.35
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Attributes | List of all members
utility::sql_database::DatabaseSessionManager Class Reference

#include <DatabaseSessionManager.hh>

Public Member Functions

virtual ~DatabaseSessionManager ()
 
sessionOP get_db_session (DatabaseMode::e db_mode, TransactionMode::e transaction_mode, platform::Size chunk_size, std::string const &db_name, std::string const &pq_schema, std::string const &host, std::string const &user, std::string const &password, platform::Size port, bool readonly=false, platform::SSize db_partition=-1)
 Acquire a database session. More...
 
sessionOP get_session_sqlite3 (std::string const &database, TransactionMode::e transaction_mode=TransactionMode::standard, platform::Size chunk_size=0, bool const readonly=false, platform::SSize db_partition=-1)
 Acquire a sqlite3 database session. More...
 
sessionOP get_session_mysql (std::string const &database, TransactionMode::e transaction_mode, platform::Size chunk_size, std::string const &host, std::string const &user, std::string const &password, platform::Size port)
 Acquire a mysql database session. More...
 
sessionOP get_session_postgres (std::string const &database, TransactionMode::e transaction_mode, platform::Size chunk_size, std::string const &pq_schema, std::string const &host, std::string const &user, std::string const &password, platform::Size port)
 Acquire a postgres database session. More...
 

Static Public Member Functions

static DatabaseSessionManagerget_instance ()
 return singleton instance of session manager More...
 

Protected Member Functions

 DatabaseSessionManager ()
 
 DatabaseSessionManager (const DatabaseSessionManager &src)
 

Private Member Functions

void set_postgres_schema_search_path (sessionOP db_session, utility::vector1< std::string > const &schema_search_path)
 

Static Private Attributes

static boost::scoped_ptr
< DatabaseSessionManager
instance_
 

Constructor & Destructor Documentation

utility::sql_database::DatabaseSessionManager::DatabaseSessionManager ( )
protected

Referenced by get_instance().

utility::sql_database::DatabaseSessionManager::DatabaseSessionManager ( const DatabaseSessionManager src)
protected
utility::sql_database::DatabaseSessionManager::~DatabaseSessionManager ( )
virtual

Member Function Documentation

sessionOP utility::sql_database::DatabaseSessionManager::get_db_session ( DatabaseMode::e  db_mode,
TransactionMode::e  transaction_mode,
platform::Size  chunk_size,
std::string const &  db_name,
std::string const &  pq_schema,
std::string const &  host,
std::string const &  user,
std::string const &  password,
platform::Size  port,
bool  readonly = false,
platform::SSize  db_partition = -1 
)
DatabaseSessionManager * utility::sql_database::DatabaseSessionManager::get_instance ( )
static

return singleton instance of session manager

References DatabaseSessionManager(), and instance_.

Referenced by basic::database::get_db_session(), and basic::database::parse_database_connection().

sessionOP utility::sql_database::DatabaseSessionManager::get_session_mysql ( std::string const &  database,
TransactionMode::e  transaction_mode,
platform::Size  chunk_size,
std::string const &  host,
std::string const &  user,
std::string const &  password,
platform::Size  port 
)
sessionOP utility::sql_database::DatabaseSessionManager::get_session_postgres ( std::string const &  database,
TransactionMode::e  transaction_mode,
platform::Size  chunk_size,
std::string const &  pq_schema,
std::string const &  host,
std::string const &  user,
std::string const &  password,
platform::Size  port 
)
sessionOP utility::sql_database::DatabaseSessionManager::get_session_sqlite3 ( std::string const &  database,
TransactionMode::e  transaction_mode = TransactionMode::standard,
platform::Size  chunk_size = 0,
bool const  readonly = false,
platform::SSize  db_partition = -1 
)

Acquire a sqlite3 database session.

details@ For SQLite3 database, the db_partition is app appends "_<mpi_rank>" to the end of the database filename This is useful when writing to an sqlite database not through the job distributor where locking causes problems

References utility::file::FileName::name(), basic::options::OptionKeys::in::file::s, utility::sql_database::DatabaseMode::sqlite3, and utility_exit_with_message.

Referenced by get_db_session(), and basic::database::get_db_session().

void utility::sql_database::DatabaseSessionManager::set_postgres_schema_search_path ( sessionOP  db_session,
utility::vector1< std::string > const &  schema_search_path 
)
private

postgres does not allow queries between databases, instead it allows tables to be created in different namespaces called "schemas". By specifing the search path, statements will be executed in a specified namespace. Note setting the search path only affects this session.

For example, to use the schema UBQdesign_stage1_r456644_120323, set set the search path with the vector ["UBQdesign_stage1_r456644_120323"]. See: http://www.postgresql.org/docs/8.1/static/ddl-schemas.html

Referenced by get_session_postgres().

Member Data Documentation

boost::scoped_ptr< DatabaseSessionManager > utility::sql_database::DatabaseSessionManager::instance_
staticprivate

Referenced by get_instance().


The documentation for this class was generated from the following files: