NCBI_PACKAGE_VERSION
84 #define NCBI_USE_ERRCODE_X Dbapi_Python 97 staticPyObject*
SetLogger(PyObject *
self, PyObject *args);
118 virtual bool Next(
void) = 0;
151 virtual bool Next(
void);
169: m_ResType(other.GetResultType())
170, m_ColumsNum(other.GetTotalColumns())
174 while(other.
Next()) {
176TRecordSet::reference record =
m_RecordSet.back();
178 for(
unsigned intcol = 1; col <=
m_ColumsNum; ++col) {
255 virtual bool Next(
void);
316 virtual bool HasRS(
void)
const;
399 virtual bool HasRS(
void)
const;
413 while(
stmt.HasMoreResults()) {
414 if(
stmt.HasRows()) {
415unique_ptr<IResultSet> rs(
stmt.GetResultSet());
532: m_UserFmt(user_fmt)
600string::size_type pos = 0;
601string::size_type prev_pos = pos;
603 if((pos =
m_StmtStr.find(
'?', pos)) != string::npos) {
607 while(pos != string::npos) {
608tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
621string::size_type pos = 0;
622string::size_type prev_pos = pos;
624 if((pos =
m_StmtStr.find(
'?', pos)) != string::npos) {
628 while(pos != string::npos) {
629tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
644string::size_type pos = 0;
645string::size_type prev_pos = pos;
651 while(pos != string::npos) {
652tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
654prev_pos = pos + param_len;
667string::size_type pos = 0;
668string::size_type prev_pos = pos;
674 while(pos != string::npos) {
675tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
677prev_pos = pos + param_len;
688string::size_type pos = 0;
689string::size_type prev_pos = pos;
698 while(pos != string::npos) {
699 stringparam_name =
m_StmtStr.substr(pos + 1, param_len - 1);
700tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
704name_map_t::iterator it = name2num.find(param_name);
705 if(it == name2num.end()) {
706it = name2num.insert(
713tmp_stmt += it->second;
715prev_pos = pos + param_len;
726string::size_type pos = 0;
727string::size_type prev_pos = pos;
733 while(pos != string::npos) {
734 stringparam_name =
m_StmtStr.substr(pos + 1, param_len - 1);
735tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
736tmp_stmt +=
"@"+ param_name;
737prev_pos = pos + param_len;
750string::size_type pos = 0;
751string::size_type prev_pos = pos;
757 while(pos != string::npos) {
758tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
760prev_pos = pos + param_len;
771string::size_type pos = 0;
772string::size_type prev_pos = pos;
781 while(pos != string::npos) {
782 stringparam_name =
m_StmtStr.substr(pos + 1, param_len - 1);
783tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
787name_map_t::iterator it = name2num.find(param_name);
788 if(it == name2num.end()) {
789it = name2num.insert(
796tmp_stmt += it->second;
798prev_pos = pos + param_len;
809string::size_type pos = 0;
810string::size_type prev_pos = pos;
816 while(pos != string::npos) {
817 stringparam_name =
m_StmtStr.substr(pos + 1, param_len - 1);
818tmp_stmt +=
m_StmtStr.substr(prev_pos, pos - prev_pos);
819tmp_stmt +=
":"+ param_name;
820prev_pos = pos + param_len;
833 stringerr =
"Cannot convert '";
835err +=
"' parameter format to '";
845string::size_type
offset,
849string::size_type pos = 0;
850 static const char* num_characters =
"0123456789";
853 if((pos != string::npos) && (pos + 1 != string::npos)) {
854string::size_type tmp_pos = 0;
856tmp_pos =
str.find_first_not_of(num_characters, pos + 1);
857 if(tmp_pos != string::npos) {
859param_len = tmp_pos - pos;
860}
else if(
str.find_first_of(num_characters, pos + 1) == pos + 1) {
862param_len =
str.size() - pos;
872string::size_type
offset,
876string::size_type pos = 0;
877 static char const* sep_characters =
" \t\n,.()-+<>=";
880 if((pos != string::npos) && (pos + 1 != string::npos)) {
881string::size_type tmp_pos = 0;
883tmp_pos =
str.find_first_of(sep_characters, pos + 1);
884 if(tmp_pos != string::npos) {
886param_len = tmp_pos - pos;
887}
else if((
str[pos + 1] >=
'A'&&
str[pos + 1] <=
'Z') ||
888(
str[pos + 1] >=
'a'&&
str[pos + 1] <=
'z')
891param_len =
str.size() - pos;
900string::size_type
offset,
904string::size_type pos = 0;
905 static char const* sep_characters =
" \t\n,.()-+<>=";
908 if((pos != string::npos) && (pos + 1 != string::npos)) {
909string::size_type tmp_pos = 0;
911tmp_pos =
str.find_first_of(sep_characters, pos + 1);
912 if(tmp_pos != string::npos) {
914param_len = tmp_pos - pos;
915}
else if((
str[pos + 1] >=
'A'&&
str[pos + 1] <=
'Z') ||
916(
str[pos + 1] >=
'a'&&
str[pos + 1] <=
'z')
919param_len =
str.size() - pos;
928struct DataSourceDeleter
931static void Delete(ncbi::IDataSource* const object)
933CDriverManager::DeleteDs( object );
938class CDataSourcePool
941CDataSourcePool(void);
942~CDataSourcePool(void);
945static CDataSourcePool& GetInstance(void);
948IDataSource& GetDataSource(
949const string& driver_name,
950const TPluginManagerParamTree* const params = NULL);
953typedef CPluginManager<I_DriverContext> TContextManager;
954typedef CPluginManagerGetter<I_DriverContext> TContextManagerStore;
955typedef map<string, AutoPtr<IDataSource, DataSourceDeleter> > TDSMap;
957CRef<TContextManager> m_ContextManager;
958TDSMap m_DataSourceMap;
961CDataSourcePool::CDataSourcePool(void)
963m_ContextManager.Reset( TContextManagerStore::Get() );
964_ASSERT( m_ContextManager );
966#if defined(NCBI_OS_MSWIN)
967// Add an additional search path ...
971CDataSourcePool::~CDataSourcePool(void)
976DataSourceCleanup(void* ptr)
978CDriverManager::DeleteDs( static_cast<ncbi::IDataSource *const>(ptr) );
982CDataSourcePool::GetInstance(void)
984static CSafeStatic<CDataSourcePool> ds_pool;
990CDataSourcePool::GetDataSource(
991const string& driver_name,
992const TPluginManagerParamTree* const params)
994TDSMap::const_iterator citer = m_DataSourceMap.find( driver_name );
996if ( citer != m_DataSourceMap.end() ) {
997return *citer->second;
1000// Build a new context ...
1001I_DriverContext* drv = NULL;
1004drv = m_ContextManager->CreateInstance(
1006NCBI_INTERFACE_VERSION(I_DriverContext),
1011catch( const CPluginManagerException& e ) {
1012throw CDatabaseError( e.what() );
1014catch ( const exception& e ) {
1015throw CDatabaseError( driver_name + " is not available :: " + e.what() );
1018throw CDatabaseError( driver_name + " was unable to load due an unknown error" );
1022IDataSource* ds = CDriverManager::CreateDs( drv );
1023m_DataSourceMap[driver_name] = ds;
1035 #if defined(NCBI_OS_CYGWIN) 1039 #elif defined(NCBI_OS_MSWIN) 1041 const DWORDbuff_size = 1024;
1043 charbuff[buff_size];
1045 const char* module_name =
NULL;
1054MEMORY_BASIC_INFORMATION mbi;
1060 if( cur_size = GetModuleFileNameA( mh, buff, buff_size ) ) {
1061 if( cur_size < buff_size ) {
1073 if(::dladdr(method_ptr, &dli) != 0) {
1096 #define DB_ERR_CODE(value, type) { value, &C##type##Error::Rethrow } 1157NCBI_NORETURN
static 1176 if(it != sc_SybaseErrCodes.end()) {
1182 switch(dbe->GetErrCode()) {
1192 if(it != sc_SybaseErrCodes.end()) {
1207 const string& driver_name,
1208 const string& db_type,
1209 const string& server_name,
1210 const string& db_name,
1211 const string& user_name,
1212 const string& user_pswd,
1213 boolsupport_standard_interface,
1216: m_DefParams(server_name, user_name, user_pswd)
1217, m_Params(m_DefParams)
1220, m_DefTransaction(
NULL)
1228 stringdb_type_uc = db_type;
1231 if( db_type_uc ==
"SYBASE"|| db_type_uc ==
"SYB") {
1233}
else if( db_type_uc ==
"MYSQL") {
1235}
else if( db_type_uc ==
"MSSQL"||
1236db_type_uc ==
"MS_SQL"||
1237db_type_uc ==
"MS SQL")
1248 while( PyDict_Next(extra_params, &
i, &
key, &
value) ) {
1366(*citer)->close(args);
1397: m_Transaction(trans)
1398, m_PoolSize(
size)
1435 throw CInternalError(
"Unable to close a transaction. There are open cursors in use.");
1458: m_Transaction( trans )
1459, m_NumOfActive( 0 )
1460, m_Started(
false)
1461, m_TransType( trans_type )
1496 throw CInternalError(
"Unable to close a transaction. There are open cursors in use.");
1561: m_ParentConnection(
conn)
1563, m_SelectConnPool( this )
1564, m_ConnectionMode( conn_mode )
1679 for( citer = tmp_CursorList.
begin(); citer != cend; ++citer ) {
1680(*citer)->CloseInternal();
1731string::size_type pos =
stmt.find_first_not_of(
" \t\n");
1732 if(pos != string::npos)
1734string::size_type pos_end =
stmt.find_first_of(
" \t\n", pos);
1735 if(pos_end == string::npos)
1736pos_end =
stmt.size();
1738 booloutput_clause_possible =
false;
1749output_clause_possible =
true;
1753output_clause_possible =
true;
1757output_clause_possible =
true;
1767output_clause_possible =
true;
1782&& output_clause_possible) {
1786 if(pos + 7 <
stmt.size()
1801: m_ParentTransaction( trans )
1803, m_Executed(
false)
1804, m_ResultStatus( 0 )
1805, m_ResultStatusAvailable(
false)
1806, m_UserHandler(
NULL)
1814: m_ParentTransaction( trans )
1816, m_Executed(
false)
1817, m_ResultStatus( 0 )
1818, m_ResultStatusAvailable(
false)
1819, m_UserHandler(
NULL)
1852 while(
m_Stmt->HasMoreResults() ) {
1853 if(
m_Stmt->HasRows() ) {
1909 m_Stmt->GetParentConn()->GetCDB_Connection()->PushMsgHandler(
handler);
1932 m_Stmt->ClearParamList();
1948 stringparam_name = name;
1950 if( param_name.size() > 0) {
1951 if( param_name[0] !=
'@') {
1952param_name =
"@"+ param_name;
1972 m_Stmt->SetParam(
value,
static_cast<unsigned int>(index) );
1997 catch(
constbad_cast&) {
1998 throw CInternalError(
"std::bad_cast exception within 'CStmtHelper::Execute'");
2003 catch(
constexception&) {
2004 throw CInternalError(
"std::exception exception within 'CStmtHelper::Execute'");
2012 return m_Stmt->GetRowCount();
2021 throw CProgrammingError(
"The previous call to executeXXX() did not produce any result set or no call was issued yet");
2031 throw CProgrammingError(
"The previous call to executeXXX() did not produce any result set or no call was issued yet");
2047 throw CProgrammingError(
"Procedure return code is not defined within this context.");
2059 while(
m_Stmt->HasMoreResults() ) {
2060 if(
m_Stmt->HasRows() ) {
2086 unsigned int cnt=
data->GetTotalColumns();
2087 for(
unsigned int i= 1;
i<=
cnt; ++
i) {
2091 switch(
data->GetType(
i)) {
2131descr.
Append(col_list);
2143: m_ParentTransaction( trans )
2144, m_Executed(
false)
2145, m_ResultStatus( 0 )
2146, m_ResultStatusAvailable(
false)
2147, m_UserHandler(
NULL)
2155: m_ParentTransaction( trans )
2157, m_Executed(
false)
2158, m_ResultStatus( 0 )
2159, m_ResultStatusAvailable(
false)
2160, m_UserHandler(
NULL)
2232 m_Stmt->GetParentConn()->GetCDB_Connection()->PushMsgHandler(
handler);
2255 stringparam_name = name;
2257 if( param_name.size() > 0) {
2258 if( param_name[0] !=
'@') {
2259param_name =
"@"+ param_name;
2268output_param =
false;
2270 if(
value.IsNull()) {
2272 m_Stmt->SetOutputParam( temp_val, param_name );
2277output_param =
true;
2291 unsigned intind =
static_cast<unsigned int>(index);
2294output_param =
false;
2296 if(
value.IsNull()) {
2298 m_Stmt->SetOutputParam( temp_val, ind );
2303output_param =
true;
2326 if(cache_results) {
2333 catch(
constbad_cast&) {
2334 throw CInternalError(
"std::bad_cast exception within 'CCallableStmtHelper::Execute'");
2339 catch(
constexception&) {
2340 throw CInternalError(
"std::exception exception within 'CCallableStmtHelper::Execute'");
2348 return m_Stmt->GetRowCount();
2357 throw CProgrammingError(
"The previous call to executeXXX() did not produce any result set or no call was issued yet");
2367 throw CProgrammingError(
"The previous call to executeXXX() did not produce any result set or no call was issued yet");
2387 throw CProgrammingError(
"Procedure return code is not defined within this context.");
2389 return m_Stmt->GetReturnStatus();
2396 throw CProgrammingError(
"The previous call to executeXXX() did not produce any result set or no call was issued yet");
2412 throw CProgrammingError(
"The previous call to executeXXX() did not produce any result set or no call was issued yet");
2429 if(
value.IsNull() ) {
2433 switch(
value.GetType() ) {
2449 #if PY_VERSION_HEX >= 0x02040000 2455 #if PY_VERSION_HEX >= 0x03070000 2460 if( !
offset.IsNull() ) {
2469(PyDateTime_FromTimestamp(args.
Get()));
2501 size_tlob_size =
value.GetBlobSize();
2504tmp_str.resize(lob_size);
2505 value.Read( (
void*)tmp_str.data(), lob_size );
2537 for(
int i= 0;
i< col_num; ++
i) {
2555 for(
int i= 0;
i< col_num; ++
i) {
2567unique_ptr<pythonpp::CCalable> error_handler;
2570}
else if(
m_Cursor!=
nullptr) {
2581 if(error_handler.get() !=
nullptr) {
2593PyErr_Fetch(&
type, &
value, &traceback);
2597PyObject_CallObject(error_handler->Get(), args.
Get());
2599Py_XDECREF(
value);
2600Py_XDECREF(traceback);
2615: m_PythonConnection( &trans->GetParentConnection() )
2616, m_PythonTransaction( trans )
2617, m_ParentTransaction( trans )
2620, m_UserHandler( this, m_PythonConnection )
2622, m_StmtHelper( trans )
2623, m_CallableStmtHelper( trans )
2624, m_ErrorHandler( m_PythonConnection.GetAttr(
"errorhandler") )
2625, m_AllDataFetched(
false)
2626, m_AllSetsFetched(
false)
2629 if( trans ==
NULL) {
2685 const size_targs_size = args.
size();
2690vector<size_t> out_params;
2692 if( args_size == 0 ) {
2693 throw CProgrammingError(
"A stored procedure name is expected as a parameter");
2694}
else if( args_size > 0 ) {
2700 throw CProgrammingError(
"A stored procedure name is expected as a parameter");
2707 if( args_size > 1 ) {
2714out_params.push_back(0);
2732 if(args_size > 1 && out_params.size() != 0) {
2734output_args.
Set(args[1]);
2742 if( rs.
Next() ) {
2746 for(
int i= 0;
i< col_num; ++
i) {
2752 const stringparam_name = md.
GetName(
i+ 1);
2810PyObject * it = PyDict_GetItemString(kwargs.
Get(),
"output_expected");
2811 if(it ==
nullptr) {
2813}
else if(PyObject_IsTrue(it)) {
2828 const size_targs_size = args.
size();
2834 if( args_size == 0 ) {
2835 throw CProgrammingError(
"An SQL statement string is expected as a parameter");
2836}
else if( args_size > 0 ) {
2843 throw CProgrammingError(
"An SQL statement string is expected as a parameter");
2850 if( args_size > 1 ) {
2900 while( PyDict_Next(dict, &
i, &
key, &
value) ) {
2914 size_tsz = seq.
size();
2915 for(
size_t i= 0;
i< sz; ++
i) {
2929 booloutput_param =
false;
2931 while( PyDict_Next(dict, &
i, &
key, &
value) ) {
2946vector<size_t>* out_params)
2949 size_tsz = seq.
size();
2951 for(
size_t i= 0;
i< sz; ++
i) {
2955 booloutput_param =
false;
2958out_params->push_back(
i);
2966 #if PY_VERSION_HEX >= 0x030a0000 2967tzinfo = PyDateTime_DATE_GET_TZINFO(dt.
Get());
2969tzinfo = dt.
GetAttr(
"tzinfo");
2971 if( !PyTZInfo_Check(tzinfo.
Get()) ) {
2978 #if PY_VERSION_HEX >= 0x03030000 2979 autodays = PyDateTime_DELTA_GET_DAYS(
delta.Get()),
2980seconds = PyDateTime_DELTA_GET_SECONDS(
delta.Get());
2985 returndays * 24 * 60 + seconds / 60;
2995 #if PY_MAJOR_VERSION < 3 3005 const stringstd_str(python_str);
3007 #if PY_VERSION_HEX >= 0x02040000 3018 if( !
offset.IsNull() ) {
3056 const size_targs_size = args.
size();
3062 if( args_size == 0 ) {
3063 throw CProgrammingError(
"A SQL statement string is expected as a parameter");
3064}
else if( args_size > 0 ) {
3071 throw CProgrammingError(
"A SQL statement string is expected as a parameter");
3075 if( args_size > 1 ) {
3089 for( citer = params.
begin(); citer != cend; ++citer ) {
3114 throw CProgrammingError(
"Sequence of parameters should be provided either as a list or as a tuple data type");
3117 throw CProgrammingError(
"A sequence of parameters is expected with the 'executemany' function");
3138 if( rs.
Next() ) {
3145 if( rs.
Next() ) {
3165 if( args.
size() > 0 ) {
3169 throw CProgrammingError(
"Invalid parameters within 'CCursor::fetchmany' function");
3181 for( ;
i< array_size && rs.
Next(); ++
i) {
3186 if(
i< array_size ) {
3195 for( ;
i< array_size && rs.
Next(); ++
i) {
3200 if(
i< array_size ) {
3228 while( rs.
Next() ) {
3238 while( rs.
Next() ) {
3336 throw CProgrammingError(
"Call get_proc_return_status after you retrieve all data.");
3342 throw CProgrammingError(
"Call get_proc_return_status after you retrieve all data.");
3369: m_PythonCursor(cursor),
3425 for(; cur_exception; cur_exception = cur_exception->
GetPredecessor()) {
3435srv_msg = cur_exception->
GetMsg();
3444PyObject *exc_ob =
NULL;
3445PyObject *errno_ob =
NULL;
3446PyObject *msg_ob =
NULL;
3449 #if PY_MAJOR_VERSION >= 3 3450errno_ob = PyLong_FromLong(db_errno);
3452errno_ob = PyInt_FromLong(db_errno);
3454 if(errno_ob ==
NULL) {
3458 #if PY_MAJOR_VERSION >= 3 3459msg_ob = PyUnicode_FromStringAndSize(db_msg.data(), db_msg.size());
3461msg_ob = PyString_FromStringAndSize(db_msg.data(), db_msg.size());
3463 if(errno_ob ==
NULL) {
3464Py_DECREF(errno_ob);
3471exc_ob = PyObject_CallFunction(err_type, (
char*)
"s", (
char*)
msg.c_str());
3472 if(exc_ob ==
NULL)
3474Py_DECREF(errno_ob);
3480 if(PyObject_SetAttrString(exc_ob, (
char*)
"srv_errno", errno_ob) == -1)
3482Py_DECREF(errno_ob);
3489Py_DECREF(errno_ob);
3492 if(PyObject_SetAttrString(exc_ob, (
char*)
"srv_msg", msg_ob) == -1)
3503PyErr_SetObject(err_type, exc_ob);
3512// Future development ...
3513class CModuleDBAPI : public pythonpp::CExtModule<CModuleDBAPI>
3516CModuleDBAPI(const char* name, const char* descr = 0)
3517: pythonpp::CExtModule<CModuleDBAPI>(name, descr)
3519PrepareForPython(this);
3523// connect(driver_name, db_type, db_name, user_name, user_pswd)
3524pythonpp::CObject connect(const pythonpp::CTuple& args);
3525pythonpp::CObject Binary(const pythonpp::CTuple& args);
3526pythonpp::CObject TimestampFromTicks(const pythonpp::CTuple& args);
3527pythonpp::CObject TimeFromTicks(const pythonpp::CTuple& args);
3528pythonpp::CObject DateFromTicks(const pythonpp::CTuple& args);
3529pythonpp::CObject Timestamp(const pythonpp::CTuple& args);
3530pythonpp::CObject Time(const pythonpp::CTuple& args);
3531pythonpp::CObject Date(const pythonpp::CTuple& args);
3535CModuleDBAPI::connect(const pythonpp::CTuple& args)
3546const pythonpp::CTuple func_args(args);
3548driver_name = pythonpp::CString(func_args[0]);
3549db_type = pythonpp::CString(func_args[1]);
3550server_name = pythonpp::CString(func_args[2]);
3551db_name = pythonpp::CString(func_args[3]);
3552user_name = pythonpp::CString(func_args[4]);
3553user_pswd = pythonpp::CString(func_args[5]);
3554} catch (const pythonpp::CError&) {
3555throw CProgrammingError("Invalid parameters within 'connect' function");
3558CConnection* conn = new CConnection( CConnParam(
3567// Feef the object to the Python interpreter ...
3568return pythonpp::CObject(conn, pythonpp::eTakeOwnership);
3570catch (const CException& e) {
3571s_ThrowDatabaseError(e);
3574// Return a dummy object ...
3575return pythonpp::CNone();
3578// This function constructs an object holding a date value.
3579// Date(year,month,day)
3581CModuleDBAPI::Date(const pythonpp::CTuple& args)
3589const pythonpp::CTuple func_args(args);
3591year = pythonpp::CInt(func_args[0]);
3592month = pythonpp::CInt(func_args[1]);
3593day = pythonpp::CInt(func_args[2]);
3594} catch (const pythonpp::CError&) {
3595throw CProgrammingError("Invalid parameters within 'Date' function");
3598// Feef the object to the Python interpreter ...
3599return pythonpp::CDate(year, month, day);
3601catch (const CDB_Exception& e) {
3602s_ThrowDatabaseError(e);
3604catch (const CException& e) {
3605pythonpp::CError::SetString(e.what());
3608// Return a dummy object ...
3609return pythonpp::CNone();
3612// This function constructs an object holding a time value.
3613// Time(hour,minute,second)
3615CModuleDBAPI::Time(const pythonpp::CTuple& args)
3623const pythonpp::CTuple func_args(args);
3625hour = pythonpp::CInt(func_args[0]);
3626minute = pythonpp::CInt(func_args[1]);
3627second = pythonpp::CInt(func_args[2]);
3628} catch (const pythonpp::CError&) {
3629throw CProgrammingError("Invalid parameters within 'Time' function");
3632// Feef the object to the Python interpreter ...
3633return pythonpp::CTime(hour, minute, second, 0);
3635catch (const CDB_Exception& e) {
3636s_ThrowDatabaseError(e);
3638catch (const CException& e) {
3639pythonpp::CError::SetString(e.what());
3642// Return a dummy object ...
3643return pythonpp::CNone();
3646// This function constructs an object holding a time stamp
3648// Timestamp(year,month,day,hour,minute,second)
3650CModuleDBAPI::Timestamp(const pythonpp::CTuple& args)
3661const pythonpp::CTuple func_args(args);
3663year = pythonpp::CInt(func_args[0]);
3664month = pythonpp::CInt(func_args[1]);
3665day = pythonpp::CInt(func_args[2]);
3666hour = pythonpp::CInt(func_args[3]);
3667minute = pythonpp::CInt(func_args[4]);
3668second = pythonpp::CInt(func_args[5]);
3669} catch (const pythonpp::CError&) {
3670throw CProgrammingError("Invalid parameters within 'Timestamp' function");
3673// Feef the object to the Python interpreter ...
3674return pythonpp::CDateTime(year, month, day, hour, minute, second, 0);
3676catch (const CDB_Exception& e) {
3677s_ThrowDatabaseError(e);
3679catch (const CException& e) {
3680pythonpp::CError::SetString(e.what());
3683// Return a dummy object ...
3684return pythonpp::CNone();
3687// This function constructs an object holding a date value
3688// from the given ticks value (number of seconds since the
3689// epoch; see the documentation of the standard Python time
3690// module for details).
3691// DateFromTicks(ticks)
3693CModuleDBAPI::DateFromTicks(const pythonpp::CTuple& args)
3697catch (const CDB_Exception& e) {
3698s_ThrowDatabaseError(e);
3700catch (const CException& e) {
3701pythonpp::CError::SetString(e.what());
3704// Return a dummy object ...
3705return pythonpp::CNone();
3708// This function constructs an object holding a time value
3709// from the given ticks value (number of seconds since the
3710// epoch; see the documentation of the standard Python time
3711// module for details).
3712// TimeFromTicks(ticks)
3714CModuleDBAPI::TimeFromTicks(const pythonpp::CTuple& args)
3718catch (const CDB_Exception& e) {
3719s_ThrowDatabaseError(e);
3721catch (const CException& e) {
3722pythonpp::CError::SetString(e.what());
3725// Return a dummy object ...
3726return pythonpp::CNone();
3729// This function constructs an object holding a time stamp
3730// value from the given ticks value (number of seconds since
3731// the epoch; see the documentation of the standard Python
3732// time module for details).
3733// TimestampFromTicks(ticks)
3735CModuleDBAPI::TimestampFromTicks(const pythonpp::CTuple& args)
3739catch (const CDB_Exception& e) {
3740s_ThrowDatabaseError(e);
3742catch (const CException& e) {
3743pythonpp::CError::SetString(e.what());
3746// Return a dummy object ...
3747return pythonpp::CNone();
3750// This function constructs an object capable of holding a
3751// binary (long) string value.
3754CModuleDBAPI::Binary(const pythonpp::CTuple& args)
3761const pythonpp::CTuple func_args(args);
3763value = pythonpp::CString(func_args[0]);
3764} catch (const pythonpp::CError&) {
3765throw CProgrammingError("Invalid parameters within 'Binary' function");
3768CBinaryType* obj = new CBinaryType(
3771// Feef the object to the Python interpreter ...
3772return pythonpp::CObject(obj, pythonpp::eTakeOwnership);
3774catch (const CDB_Exception& e) {
3775s_ThrowDatabaseError(e);
3777catch (const CException& e) {
3778pythonpp::CError::SetString(e.what());
3781return pythonpp::CNone();
3891(
"Unknown error in python_ncbi_dbapi::ReleaseGlobalLock");
3901 Connect(PyObject *
self, PyObject *args, PyObject *kwargs)
3919 static const char*
constkwnames[] = {
3920 "driver",
"type",
"dsn",
"database",
"user",
"password",
3921 "support_standard_interface",
"extra",
nullptr 3923PyObject *py_driver_name;
3924PyObject *py_db_type;
3925PyObject *py_server_name;
3926PyObject *py_db_name;
3927PyObject *py_user_name;
3928PyObject *py_user_pswd;
3929PyObject *py_support_standard_interface =
nullptr;
3930PyObject *py_extra_params =
nullptr;
3932 intstatus = PyArg_ParseTupleAndKeywords
3933(args, kwargs,
"UUUUUU|OO:connect", (
char**) kwnames,
3934&py_driver_name, &py_db_type, &py_server_name, &py_db_name,
3935&py_user_name, &py_user_pswd, &py_support_standard_interface,
3941driver_name = py_driver_name;
3942db_type = py_db_type;
3943server_name = py_server_name;
3944db_name = py_db_name;
3945user_name = py_user_name;
3946user_pswd = py_user_pswd;
3947 if(py_extra_params !=
nullptr) {
3948extra_params = py_extra_params;
3949 if(py_support_standard_interface !=
nullptr) {
3950support_standard_interface = py_support_standard_interface;
3952}
else if(py_support_standard_interface !=
nullptr) {
3956 if(func_args.
size() > 6
3958extra_params = py_support_standard_interface;
3960support_standard_interface = py_support_standard_interface;
3974support_standard_interface,
3999 Date(PyObject *
self, PyObject *args)
4001 #if PY_VERSION_HEX < 0x02040000 4043 Time(PyObject *
self, PyObject *args)
4045 #if PY_VERSION_HEX < 0x02040000 4090 #if PY_VERSION_HEX < 0x02040000 4263 static void Declare(
const char* name, PyMethodDef* methods);
4267 #if PY_MAJOR_VERSION >= 3 4268 static structPyModuleDef m_ModuleDef;
4273 #if PY_MAJOR_VERSION >= 3 4275PyModuleDef_HEAD_INIT,
4290 #if PY_MAJOR_VERSION >= 3 4291m_ModuleDef.m_name = name;
4292m_ModuleDef.m_methods = methods;
4293 m_Module= PyModule_Create(&m_ModuleDef);
4295 m_Module= Py_InitModule(
const_cast<char*
>(name), methods);
4303 "return_strs_as_unicode(bool_flag_value) " 4304 "-- set global flag indicating that all strings returned from database " 4305 "should be presented to Python as unicode strings (if value is True) or " 4306 " as regular strings in UTF-8 encoding (if value is False - the default one). " 4307 "NOTE: This is not a part of the Python Database API Specification v2.0." 4310 "release_global_lock(bool_flag_value) " 4311 "-- set global flag indicating that blocking database operations " 4312 "should run with Python's global interpreter lock released (if value " 4313 "is True) or with it held (if value is False, the default for now)." 4314 "NOTE: This is not a part of the Python Database API Specification " 4318METH_VARARGS | METH_KEYWORDS, (
char*)
4319 "connect([driver=]driver_name, [type=]db_type, [dsn=]server_name," 4320 " [database=]database_name, [user=]userid, [password=]password," 4321 " [[support_standard_interface=]support_standard_interface]," 4322 " [[extra=]extra]) -- connect with the specified parameters" 4325(
char*)
"set_logger(logger) " 4326 "-- log through the specified logger. (This module otherwise defaults " 4327 "to going directly through the root logger.) " 4328 "NOTE: This is not a part of the Python Database API Specification " 4330{(
char*)
"Date", (PyCFunction)
python::Date, METH_VARARGS, (
char*)
"Date"},
4331{(
char*)
"Time", (PyCFunction)
python::Time, METH_VARARGS, (
char*)
"Time"},
4332{(
char*)
"Timestamp", (PyCFunction)
python::Timestamp, METH_VARARGS, (
char*)
"Timestamp"},
4333{(
char*)
"DateFromTicks", (PyCFunction)
python::DateFromTicks, METH_VARARGS, (
char*)
"DateFromTicks"},
4334{(
char*)
"TimeFromTicks", (PyCFunction)
python::TimeFromTicks, METH_VARARGS, (
char*)
"TimeFromTicks"},
4336{(
char*)
"Binary", (PyCFunction)
python::Binary, METH_VARARGS, (
char*)
"Binary"},
4577 #if PY_VERSION_HEX >= 0x03020000 4584: m_LoggingModule(PyImport_ImportModule(
"logging"))
4585, m_LoggingDict(m_LoggingModule.GetDict()), m_Logger(1)
4586, m_LoggerClass(m_LoggingDict.GetItem(
"Logger"))
4587#
ifPY_VERSION_HEX >= 0x03020000
4588, m_HasHandlers(m_LoggerClass.GetAttr(
"hasHandlers"))
4589, m_IsConfigured(
false)
4595 autoroot_logger = get_logger.
Apply();
4638 #if PY_VERSION_HEX >= 0x03020000 4639 if( !m_IsConfigured ) {
4640m_IsConfigured = m_HasHandlers.Apply(
m_Logger);
4641 if( !m_IsConfigured ) {
4654s.erase(0, s.find_first_not_of(
" ", s.find_first_of(
" ") + 1));
4686 "set_logger: expected logging.logger but got "+
type_name);
4732 stringname(
"python_ncbi_dbapi.ini");
4735 int Run(
void)
override{
return0; }
4743s_app->FlushDiag(
nullptr);
4782 #if PY_VERSION_HEX >= 0x02040000 4808 const stringconnection_name(module_name +
".Connection");
4820 const stringtransaction_name(module_name +
".Transaction");
4831 const stringcursor_name(module_name +
".Cursor");
4849 const stringcursor_iter_name(module_name +
".__CursorIterator__");
4859 if(PyModule_AddObject(module,
const_cast<char*
>(
"BINARY"),
4868 if( PyModule_AddObject(module,
const_cast<char*
>(
"NUMBER"), (PyObject*)&
python::CNumber::GetType() ) == -1 ) {
4876 if( PyModule_AddObject(module,
const_cast<char*
>(
"ROWID"), (PyObject*)&
python::CRowID::GetType() ) == -1 ) {
4897 static charstr_class[] =
"__class__";
4898 static charstr_errorhandler[] =
"errorhandler";
4899 staticPyMemberDef conn_members[] = {
4900{str_class, T_OBJECT_EX, 0, READONLY,
NULL},
4901{str_errorhandler, T_OBJECT_EX, 0, 0,
NULL},
4904extt->tp_members = conn_members;
4905 if( PyType_Ready(extt) == -1 ) {
4908 if( PyModule_AddObject(module,
const_cast<char*
>(
"Connection"), (PyObject*)extt ) == -1 ) {
4912extt->tp_members = conn_members;
4913 if( PyType_Ready(extt) == -1 ) {
4916 if( PyModule_AddObject(module,
const_cast<char*
>(
"Transaction"), (PyObject*)extt ) == -1 ) {
4921 static charstr_rowcount[] =
"rowcount";
4922 static charstr_messages[] =
"messages";
4923 static charstr_description[] =
"description";
4924 staticPyMemberDef members[] = {
4925{str_rowcount, T_LONG, 0, READONLY,
NULL},
4926{str_messages, T_OBJECT_EX, 0, READONLY,
NULL},
4927{str_description, T_OBJECT_EX, 0, READONLY,
NULL},
4928{str_errorhandler, T_OBJECT_EX, 0, 0,
NULL},
4929{str_class, T_OBJECT_EX, 0, READONLY,
NULL},
4932extt->tp_members = members;
4934 if( PyType_Ready(extt) == -1 ) {
4937 if( PyModule_AddObject(module,
const_cast<char*
>(
"Cursor"), (PyObject*)extt ) == -1 ) {
4943 if( PyType_Ready(extt) == -1 ) {
4946 if( PyModule_AddObject(module,
const_cast<char*
>(
"__CursorIterator__"), (PyObject*)extt ) == -1 ) {
5050 #ifdef NCBI_OS_DARWINvoid SetDriverName(const string &name)
void SetDatabaseName(const string &name)
void SetParam(const string &key, const string &value)
void SetServerType(EServerType type)
void SetEncoding(EEncoding encoding)
virtual TSvrRef GetServer(const string &service)
Map a service to a server.
int Run(void) override
Run the application.
static CNcbiApplication * Instance(void)
Singleton method.
static SSystemFastMutex & GetMutex(void)
vector< pythonpp::CCalable > m_LoggingFunctions
pythonpp::CTuple m_Logger
void Post(const SDiagMessage &mess) override
Post message to handler.
pythonpp::CModule m_LoggingModule
pythonpp::CObject m_LoggerClass
pythonpp::CDict m_LoggingDict
void SetLogger(pythonpp::CObject logger)
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
TBase::const_iterator const_iterator
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
virtual const IResultSetMetaData & GetMetaData(void) const
Get Metadata.
virtual bool Next(void)
Get next row.
CCachedResultSet(IResultSet &other)
virtual ~CCachedResultSet(void)
virtual const CVariant & GetVariant(const CDBParamVariant ¶m)
Retrieve a CVariant class describing the data stored in a given column.
deque< CVariant > TRecord
virtual unsigned int GetTotalColumns(void)
Get total columns.
const EDB_ResType m_ResType
virtual EDB_ResType GetResultType(void)
Get result type.
unique_ptr< const IResultSetMetaData > m_MetaData
deque< TRecord > TRecordSet
const unsigned int m_ColumsNum
CTransaction *const m_ParentTransaction
CCallableStmtHelper(CTransaction *trans)
int GetReturnStatus(void)
long GetRowCount(void) const
unique_ptr< ICallableStatement > m_Stmt
unique_ptr< CResultSetProxy > m_RSProxy
void SetStr(const CStmtStr &stmt, CDB_UserHandler *handler)
void SetParam(const string &name, const CVariant &value, bool &output_param)
void CreateStmt(CDB_UserHandler *handler)
CDB_UserHandler * m_UserHandler
~CCallableStmtHelper(void)
void FillDescription(pythonpp::CList &descr)
void Execute(bool cache_results=false)
CVariantSet & GetRS(void)
bool m_ResultStatusAvailable
CCPPToolkitConnParams m_Params
CTransaction * CreateTransaction(void)
void DestroyTransaction(CTransaction *trans)
EConnectionMode m_ConnectionMode
pythonpp::CObject __enter__(const pythonpp::CTuple &args)
CDBDefaultConnParams m_DefParams
pythonpp::CObject m_ErrorHandler
pythonpp::CObject commit(const pythonpp::CTuple &args)
CConnection(const string &driver_name, const string &db_type, const string &server_name, const string &db_name, const string &user_name, const string &user_pswd, bool support_standard_interface, const pythonpp::CDict &extra_params)
IConnection * MakeDBConnection(void) const
pythonpp::CObject close(const pythonpp::CTuple &args)
pythonpp::CObject rollback(const pythonpp::CTuple &args)
CTransaction * m_DefTransaction
CTransaction & GetDefaultTransaction(void)
pythonpp::CObject cursor(const pythonpp::CTuple &args)
pythonpp::CObject transaction(const pythonpp::CTuple &args)
CCursorIter(CCursor *cursor)
pythonpp::CObject fetchmany(const pythonpp::CTuple &args)
Fetch the next set of rows of a query result, returning a sequence of sequences (e....
pythonpp::CList m_InfoMessages
pythonpp::CObject __enter__(const pythonpp::CTuple &args)
pythonpp::CList m_DescrList
void AddInfoMessage(const string &message)
pythonpp::CObject m_Description
pythonpp::CObject fetchall(const pythonpp::CTuple &args)
Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e....
PyObject * CreateIter(void)
bool NextSetInternal(void)
CCursor(CTransaction *trans)
pythonpp::CObject setinputsizes(const pythonpp::CTuple &args)
This can be used before a call to executeXXX() to predefine memory areas for the operation's paramete...
pythonpp::CObject close(const pythonpp::CTuple &args)
Close the cursor now (rather than whenever __del__ is called).
pythonpp::CObject fetchone(const pythonpp::CTuple &args)
Fetch the next row of a query result set, returning a single sequence, or None when no more data is a...
pythonpp::CObject get_proc_return_status(const pythonpp::CTuple &args)
CCallableStmtHelper m_CallableStmtHelper
CUserHandler m_UserHandler
pythonpp::CObject execute(const pythonpp::CTuple &args, const pythonpp::CDict &kwargs)
Prepare and execute a database operation (query or command).
pythonpp::CObject m_ErrorHandler
void SetupParameters(const pythonpp::CDict &dict, CStmtHelper &stmt)
pythonpp::CObject callproc(const pythonpp::CTuple &args)
Call a stored database procedure with the given name.
CVariant GetCVariant(const pythonpp::CObject &obj) const
pythonpp::CObject setoutputsize(const pythonpp::CTuple &args)
Set a column buffer size for fetches of large columns (e.g.
pythonpp::CObject executemany(const pythonpp::CTuple &args, const pythonpp::CDict &kwargs)
Prepare a database operation (query or command) and then execute it against all parameter sequences o...
CTransaction & GetTransaction(void)
pythonpp::CObject nextset(const pythonpp::CTuple &args)
This method will make the cursor skip to the next available set, discarding any remaining rows from t...
static void Declare(const char *name, PyMethodDef *methods)
static PyObject * m_Module
CDMLConnPool(CTransaction *trans, ETransType trans_type=eImplicitTrans)
void rollback(void) const
const ETransType m_TransType
IStatement & GetLocalStmt(void) const
unique_ptr< IStatement > m_LocalStmt
const CConnection & GetConnection(void) const
IConnection * Create(void)
void Destroy(IConnection *db_conn)
unique_ptr< IConnection > m_DMLConnection
void x_Init(const CDB_Exception &e, PyObject *err_type)
TFormat GetDriverFmt(void) const
static const char * GetName(TFormat fmt)
TFormat GetUserFmt(void) const
CParamFmt(TFormat user_fmt=eTSQL, TFormat drv_fmt=eTSQL)
virtual unsigned int GetTotalColumns(void)
Get total columns.
virtual const CVariant & GetVariant(const CDBParamVariant ¶m)
Retrieve a CVariant class describing the data stored in a given column.
virtual EDB_ResType GetResultType(void)
Get result type.
CRealResultSet(IResultSet *other)
virtual bool Next(void)
Get next row.
virtual ~CRealResultSet(void)
virtual const IResultSetMetaData & GetMetaData(void) const
Get Metadata.
virtual bool MoveToLastRS(void)
virtual ~CRealSetProxy(void)
virtual bool HasRS(void) const
virtual CVariantSet & GetRS(void)
unique_ptr< CVariantSet > m_VariantSet
virtual bool MoveToNextRS(void)
CRealSetProxy(ICallableStatement &stmt)
ICallableStatement * m_Stmt
virtual void DumpResult(void)
const CConnection & GetConnection(void) const
TConnectionList m_ConnPool
void Destroy(IConnection *db_conn)
IConnection * Create(void)
CSelectConnPool(CTransaction *trans, size_t size=3)
TConnectionList m_ConnList
int GetReturnStatus(void)
void FillDescription(pythonpp::CList &descr)
CDB_UserHandler * m_UserHandler
void SetParam(const string &name, const CVariant &value)
unique_ptr< IResultSet > m_RS
CStmtHelper(CTransaction *trans)
void SetStr(const CStmtStr &stmt, CDB_UserHandler *handler)
long GetRowCount(void) const
CTransaction *const m_ParentTransaction
unique_ptr< IStatement > m_Stmt
void CreateStmt(CDB_UserHandler *handler)
bool m_ResultStatusAvailable
string::size_type find_named(const string &str, string::size_type offset, int ¶m_len)
EStatementType GetType(void) const
void SetStr(const string &str, EStatementType default_type=estSelect, const CParamFmt &fmt=CParamFmt(), ETriState output_expected=eTriState_Unknown)
string::size_type find_numeric(const string &str, string::size_type offset, int ¶m_len)
string::size_type find_TSQL(const string &str, string::size_type offset, int ¶m_len)
string GetStr(void) const
CDMLConnPool m_DMLConnPool
pythonpp::CObject __enter__(const pythonpp::CTuple &args)
void CloseOpenCursors(void)
IConnection * CreateSelectConnection(void)
pythonpp::CObject commit(const pythonpp::CTuple &args)
pythonpp::CObject rollback(const pythonpp::CTuple &args)
CTransaction(CConnection *conn, pythonpp::EOwnershipFuture ownnership=pythonpp::eOwned, EConnectionMode conn_mode=eSimpleMode)
const CConnection & GetParentConnection(void) const
IConnection * CreateDMLConnection(void)
void RollbackInternal(void) const
CSelectConnPool m_SelectConnPool
CCursor * CreateCursor(void)
pythonpp::CObject close(const pythonpp::CTuple &args)
void DestroyCursor(CCursor *cursor)
void DestroySelectConnection(IConnection *db_conn)
void CommitInternal(void) const
void DestroyDMLConnection(IConnection *db_conn)
const EConnectionMode m_ConnectionMode
pythonpp::CObject m_PythonConnection
pythonpp::CObject cursor(const pythonpp::CTuple &args)
virtual bool HandleIt(CDB_Exception *ex)
Handle the exceptions resulting from a native API call, one-by-one.
pythonpp::CObject m_PythonConnection
virtual ~CVariantSetProxy(void)
virtual bool MoveToNextRS(void)
virtual bool MoveToLastRS(void)
CRef< CVariantSet > m_CurResultSet
CVariantSetProxy(ICallableStatement &stmt)
deque< CRef< CVariantSet > > TCachedSet
virtual bool HasRS(void) const
virtual CVariantSet & GetRS(void)
virtual void DumpResult(void)
virtual const IResultSetMetaData & GetMetaData(void) const =0
Get Metadata.
virtual EDB_ResType GetResultType(void)=0
Get result type.
virtual bool Next(void)=0
Get next row.
virtual const CVariant & GetVariant(const CDBParamVariant ¶m)=0
Retrieve a CVariant class describing the data stored in a given column.
virtual unsigned int GetTotalColumns(void)=0
Get total columns.
virtual ~CVariantSet(void)
Destructor.
void Cleanup(CVariant &value)
CWarning(const string &msg)
static bool HasSameType(PyObject *obj)
static bool HasExactSameType(PyObject *obj)
CObject Apply(void) const
Call.
static bool HasSameType(PyObject *obj)
int GetMicroSecond(void) const
int GetMinute(void) const
int GetSecond(void) const
static bool HasSameType(PyObject *obj)
void SetItem(const string &key, const CObject &obj)
CObject GetItem(const string &s) const
static bool HasSameType(PyObject *obj)
static void SetString(const string &msg)
void RWAttr(const string &name, long &value)
static void Declare(const char *name, const char *descr=0, PyTypeObject *base=&PyBaseObject_Type)
void ROAttr(const string &name, long &value)
static CExtType & GetType(void)
static void PrepareForPython(CExtObject< CBinaryType > *self)
static CClass< 1 > Def(const char *name, TMethodVarArgsFunc func, const char *doc=0)
static CObject & GetTypeObject(void)
void SetName(const char *name)
static bool HasSameType(PyObject *obj)
static bool HasSameType(PyObject *obj)
void SetItem(int offset, const CObject &obj)
void Append(const CObject &obj)
static bool HasSameType(PyObject *obj)
static bool HasSameType(PyObject *obj)
static void AddConst(const string &name, const string &value)
static void Declare(const string &name, PyMethodDef *methods, inquiry cleanup_hook=NULL)
static PyObject * GetPyModule(void)
static bool HasExactSameType(PyObject *obj)
static bool HasSameType(PyObject *obj)
void Set(PyObject *obj, EOwnership ownership)
Not exception-safe this time.
PyTypeObject * GetObjType(void) const
PyObject * Get(void) const
CObject GetAttr(const std::string &name) const
virtual size_type size() const
static bool HasSameType(PyObject *obj)
CThreadingGuard â "Anti-guard" for Python's global interpreter lock, which it temporarily releases to...
static void SetMayRelease(bool may_release)
int GetMinute(void) const
int GetSecond(void) const
int GetMicroSecond(void) const
static bool HasSameType(PyObject *obj)
void SetItem(int offset, const CObject &obj)
void SetItemFast(int offset, PyObject *obj)
size_type size(void) const
static bool HasSameType(PyObject *obj)
CObject GetItem(int offset) const
static void Declare(const string &name)
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator end() const
parent_type::const_iterator const_iterator
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
#define DBLB_INSTALL_DEFAULT()
Easy-to-use macro to install the default DBAPI service mapper.
static CS_CONNECTION * conn
static const char * str(char *buf, int n)
ETriState
Enumeration to represent a tristate value.
virtual bool LoadConfig(CNcbiRegistry ®, const string *conf, CNcbiRegistry::TFlags reg_flags)
Load settings from the configuration file to the registry.
CNcbiRegistry & GetRWConfig(void)
Get the application's cached configuration parameters, accessible for read-write for an application's...
@ eTriState_False
The value is equivalent to false/no.
@ eTriState_True
The value is equivalent to true/yes.
@ eTriState_Unknown
The value is indeterminate.
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
virtual bool Next()=0
Get next row.
virtual string GetName(const CDBParamVariant ¶m) const =0
Get name of column.
virtual IResultSet * GetResultSet()=0
Get resulset.
virtual bool HasMoreResults()=0
Check for more results available.
virtual const IResultSetMetaData * GetMetaData(EOwnership ownership=eNoOwnership)=0
Get Metadata.
virtual CDB_Connection * GetCDB_Connection()=0
Returns the internal driver connection object.
virtual EDB_ResType GetResultType()=0
Get result type.
virtual IStatement * GetStatement()=0
Get statement object for regular SQL queries.
virtual unsigned int GetTotalColumns()=0
Get total columns.
virtual const CVariant & GetVariant(const CDBParamVariant ¶m)=0
Retrieve a CVariant class describing the data stored in a given column.
virtual I_DriverContext * GetDriverContext()=0
Returns the pointer to the general driver interface.
virtual ICallableStatement * GetCallableStatement(const string &proc)=0
Get callable statement object for stored procedures.
virtual void Connect(const string &user, const string &password, const string &server, const string &database=kEmptyStr)=0
Connect to a database.
virtual bool HasRows()=0
Check if resultset has rows.
virtual void ExecuteUpdate(const string &sql)=0
Executes SQL statement with no results returned.
virtual IConnection * CreateConnection(EOwnership ownership=eNoOwnership)=0
IDataSource * MakeDs(const CDBConnParams ¶ms, const string &tag=kEmptyStr)
static CDriverManager & GetInstance()
void AddDllSearchPath(const string &path)
Add path for the DLL lookup.
int GetDBErrCode(void) const
int GetSybaseSeverity(void) const
bool IsPositional(void) const
virtual void PushDefConnMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Add `per-connection' err.message handler "h" to the stack of default handlers which are inherited by ...
virtual void PushCntxMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Add message handler "h" to process 'context-wide' (not bound to any particular connection) error mess...
unsigned int GetPosition(void) const
EDB_ResType
EDB_ResType::
virtual void PushMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)
Put the message handler into message handler stack.
@ eDateTimeOffset
DATETIMEOFFSET (MS); no Sybase equivalent.
static CVariant VarBinary(const void *p, size_t len)
void Write(string &str, TDiagWriteFlags flags=fNone) const
Binary OR of "EDiagWriteFlags".
TExtraArgs m_ExtraArgs
If event type is "extra", contains the list of arguments.
static bool IsSetOldPostFormat(void)
Check old/new format flag (for compatibility only)
const char * m_Buffer
Not guaranteed to be '\0'-terminated!
EDiagSev m_Severity
Severity level.
#define NCBI_CURRENT_FUNCTION
Get current function name.
int CompareDiagPostLevel(EDiagSev sev1, EDiagSev sev2)
Compare two severities.
CDiagHandler * GetDiagHandler(bool take_ownership=false, bool *current_ownership=0)
Get the currently set diagnostic handler class.
size_t m_BufferLen
Length of m_Buffer.
void SetDiagHandler(CDiagHandler *handler, bool can_delete=true)
Set the diagnostic handler using the specified diagnostic handler class.
static void SetOldPostFormat(bool value)
Set old/new format flag.
@ fNoEndl
No end of line.
@ fNoPrefix
No std prefix.
@ eDiag_Trace
Trace message.
@ eDiag_Info
Informational message.
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
@ eDiag_Fatal
Fatal error â guarantees exit(or abort)
@ eDiag_Critical
Critical error message.
@ eDiagSevMax
Verbosity level for max. severity.
#define NCBI_CATCH_ALL_X(err_subcode, message)
const string & GetMsg(void) const
Get message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
const CException * GetPredecessor(void) const
Get "previous" exception from the backlog.
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
size_type find(const CTempString match, size_type pos=0) const
Find the first instance of the entire matching string within the current string, beginning at an opti...
static string & ToUpper(string &str)
Convert string to upper case â string& version.
static const size_type npos
int Minute(void) const
Get minute.
void SetMinute(int minute)
Set minute.
TSeconds TimeZoneOffset(void) const
Get difference between local timezone for current time object and UTC in seconds.
void SetSecond(int second)
Set second.
void SetMicroSecond(long microsecond)
Set microseconds.
long NanoSecond(void) const
Get nano-seconds.
int Year(void) const
Get year.
void SetHour(int hour)
Set hour.
time_t GetTimeT(void) const
Get time in time_t format.
int Day(void) const
Get day.
int Hour(void) const
Get hour.
int Second(void) const
Get second.
int Month(void) const
Get month.
@ eCurrent
Use current time. See also CCurrentTime.
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format
if(yy_accept[yy_current_state])
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
static string RetrieveModuleFileName(void)
PyObject * s_GetCursorIter(PyObject *curs_obj)
static void s_FillDescription(pythonpp::CList &descr, const IResultSetMetaData *data)
static PyObject * Binary(PyObject *self, PyObject *args)
static PyObject * Timestamp(PyObject *self, PyObject *args)
static PyObject * ReturnStrsAsUnicode(PyObject *self, PyObject *args)
static CNullable< short > x_GetUTCOffset(const pythonpp::CDateTime &dt)
EStatementType RetrieveStatementType(const string &stmt, EStatementType default_type, ETriState output_expected)
SStaticPair< int, FRethrow > TDBErrCodePair
static PyObject * TimeFromTicks(PyObject *self, PyObject *args)
PyObject * s_CursorIterNext(PyObject *iter_obj)
PyObject * s_GetCursorIterFromIter(PyObject *iter_obj)
static const TDBErrCodePair kClientErrCodes[]
static PyObject * DateFromTicks(PyObject *self, PyObject *args)
static PyObject * SetLogger(PyObject *self, PyObject *args)
static PyObject * ReleaseGlobalLock(PyObject *self, PyObject *args)
static PyObject * Time(PyObject *self, PyObject *args)
void(* FRethrow)(const CDB_Exception &)
static PyObject * Connect(PyObject *self, PyObject *args, PyObject *kwargs)
static PyObject * TimestampFromTicks(PyObject *self, PyObject *args)
DEFINE_STATIC_ARRAY_MAP(TDBErrCodeMap, sc_ClientErrCodes, kClientErrCodes)
static ETriState s_IsOutputExpected(const pythonpp::CDict &kwargs)
pythonpp::CTuple MakeTupleFromResult(IResultSet &rs)
pythonpp::CObject ConvertCVariant2PCObject(const CVariant &value)
static PyObject * Date(PyObject *self, PyObject *args)
static const TDBErrCodePair kSybaseErrCodes[]
CStaticArrayMap< int, FRethrow > TDBErrCodeMap
static void s_ThrowDatabaseError(const CException &e)
PyObject * DecRefCount(PyObject *obj)
PyObject * IncRefCount(PyObject *obj)
const GenericPointer< typename T::ValueType > T2 value
#define NCBI_PACKAGE_VERSION
Static variables safety - create on demand, destroy on application termination.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines access to miscellaneous global configuration settings.
const char * NCBI_GetDefaultRunpath(void)
Get default run path.
Int4 delta(size_t dimension_, const Int4 *score_)
#define DB_ERR_CODE(value, type)
static void s_RestoreOrigDiagHandler(void)
static struct PyMethodDef python_ncbi_dbapi_methods[]
static PyObject * init_common(const string &module_name)
static int s_OnClear(PyObject *)
#define PYDBAPI_MODINIT_FUNC(name)
#define PYDBAPI_SUPPORT_DIR
#define PYDBAPI_MOD_RETURN
static bool s_WasUsingOldPostFormat
bool g_PythonStrDefToUnicode
Flag showing whether all pythonpp::CString objects should be created as Python unicode strings (TRUE ...
static CDiagHandler * s_OrigDiagHandler
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
static const char * type_name(CS_INT value)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4