1 #ifndef DBAPI_DRIVER___INTERFACES__HPP
2 #define DBAPI_DRIVER___INTERFACES__HPP
49 #if defined(_MSC_VER) && _MSC_VER < 1920
51 #pragma warning(disable : 4996)
117 return m_IsPositional;
133 string GetName(ENameFormat
format)
const;
135 static string MakePlainName(
const CTempString& name);
165 virtual unsigned int GetNum(
void)
const = 0;
227 bool out_param =
false
243 bool out_param =
false
333 virtual string GetDriverName(
void)
const;
334 virtual Uint4 GetProtocolVersion(
void)
const;
335 virtual EEncoding GetEncoding(
void)
const;
337 virtual string GetServerName(
void)
const;
338 virtual string GetDatabaseName(
void)
const;
339 virtual string GetUserName(
void)
const;
340 virtual string GetPassword(
void)
const;
349 virtual string GetParam(
const string&
key)
const;
494 virtual bool More(
const string& query_text) = 0;
562 bool log_it =
true) = 0;
594 bool discard_results =
true) = 0;
620 virtual size_t SendChunk(
const void* pChunk,
size_t nofBytes) = 0;
666 virtual const char*
ItemName(
unsigned int item_num)
const = 0;
753 bool* is_null = 0) = 0;
814 fPasswordEncrypted = 0x2,
931 const string& srv_name,
932 const string& user_name,
933 const string& passwd,
934 TConnectionMode
mode,
935 bool reusable =
false,
989 const string& srv_name,
990 const string& user_name,
991 const string& passwd,
993 TConnectionMode
mode = 0,
994 bool reusable =
false,
1020 const string& pool_name =
"")
1023 const string& pool_name =
"")
const = 0;
1083 eReturnITDescriptors = eReturnBlobDescriptors,
1084 eReturnComputeResults
1161 virtual string GetDriverName(
void)
const;
1218 const string&
query,
1219 unsigned int batch_size) = 0;
1221 const string&
query)
1223 return Cursor(cursor_name,
query, 1);
1245 bool discard_results =
true)
1265 bool log_it =
true) = 0;
1410 virtual string GetVersionString(
void)
const;
1418 return LangCmd(lang_query);
1423 return RPC(rpc_name);
1432 const string&
query,
1434 unsigned int batch_size)
1436 return Cursor(cursor_name,
query, batch_size);
1449 #if defined(_MSC_VER) && _MSC_VER < 1920
1450 #pragma warning(pop)
CParamRecordset:: Parametrized recordset.
CParamStmt:: Parametrized statement.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
I_LangCmd:: I_RPCCmd:: I_BCPInCmd:: I_CursorCmd:: I_SendDataCmd::
static const char table_name[]
@ eNoOwnership
No ownership is assumed.
bool IsPositional(void) const
virtual bool Close(void)=0
Close the cursor.
virtual EEncoding GetEncoding(void) const =0
virtual CDB_Result * Open(void)=0
Open the cursor.
virtual bool IsAlive(void)=0
Check out if connection is alive.
virtual int CurrentItemNo(void) const =0
Return current item number we can retrieve (0,1,...)
typedef NCBI_PARAM_TYPE(dbapi, conn_use_encrypt_data) TDbapi_ConnUseEncryptData
virtual const string & PoolName(void) const =0
Find out which connection pool this connection belongs to.
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 EDB_Type GetDataType(const CDBParamVariant ¶m) const =0
Get data type for column in the resultset.
CDB_BCPInCmd * BCPIn(const string &table_name, unsigned int)
virtual const impl::CDBHandlerStack & GetOpeningMsgHandlers(void) const =0
virtual CDB_SendDataCmd * SendDataCmd(I_BlobDescriptor &desc, size_t data_size, bool log_it=true, bool discard_results=true)=0
Create send-data command.
virtual bool Cancel(void)=0
virtual CDB_CursorCmd * Cursor(const string &cursor_name, const string &query, unsigned int batch_size)=0
Cursor.
virtual CDB_Connection * MakePooledConnection(const CDBConnParams ¶ms)=0
Create connection object WITHOUT using of Load Balancer / connection factory.
virtual CDB_RPCCmd * RPC(const string &rpc_name)=0
Remote procedure call.
CDB_LangCmd * LangCmd(const string &lang_query, unsigned int)
virtual bool HasMoreResults(void) const =0
virtual bool Cancel(void)=0
Cancel the command execution.
const CDBConnParams & GetThis(void) const
virtual const string & GetName(const CDBParamVariant ¶m, CDBParamVariant::ENameFormat format=CDBParamVariant::eSQLServerName) const =0
Get name of column.
virtual size_t GetMaxSize(const CDBParamVariant ¶m) const =0
Get maximum size in bytes for column.
ECapability
Report if the driver supports this functionality.
NCBI_DBAPIDRIVER_EXPORT
I_DriverContext::
virtual bool SendData(I_BlobDescriptor &desc, CDB_Stream &lob, bool log_it=true)=0
Shortcut to send text and image to the server without using the "Send-data" command (SendDataCmd)
CDB_CursorCmd * Cursor(const string &cursor_name, const string &query, unsigned int, unsigned int batch_size)
virtual size_t SendChunk(const void *pChunk, size_t nofBytes)=0
Send chunk of data to the server.
virtual CDB_BCPInCmd * BCPIn(const string &table_name)=0
"Bulk copy in" command
virtual const string & DatabaseName(void) const =0
Get the database name.
virtual unsigned int GetNum(void) const =0
Get total number of columns in resultset.
virtual string GetApplicationName(void) const =0
Return application name.
virtual bool Close(void)=0
Close an open connection.
virtual bool Update(const string &table_name, const string &upd_query)=0
Update the last fetched row.
virtual bool WasSent(void) const =0
Implementation-specific.
I_BlobDescriptor I_ITDescriptor
virtual unsigned int GetTimeout(void) const =0
Get connection timeout.
CDB_CursorCmd * Cursor(const string &cursor_name, const string &query)
virtual int DescriptorType(void) const =0
virtual bool SendRow(void)=0
Send row to the server.
virtual EServerType GetServerType(void) const =0
virtual size_t GetTimeout(void) const =0
Get connection timeout.
virtual unsigned int NofItems(void) const =0
Get # of items (columns) in the result.
virtual CDBParams & GetBindParams(void)=0
Get meta-information about binded parameters.
virtual string GetPassword(void) const =0
virtual void DumpResults(void)=0
Dump the results of the command if result processor is installed for this connection,...
virtual CDB_LangCmd * LangCmd(const string &lang_query)=0
These methods: LangCmd(), RPC(), BCPIn(), Cursor() and SendDataCmd() create and return a "command" ob...
virtual I_DriverContext * Context(void) const =0
Get pointer to the driver context.
virtual bool SetLoginTimeout(unsigned int nof_secs=0)=0
Set login timeout.
virtual ~CParamRecordset(void)
virtual const char * ItemName(unsigned int item_num) const =0
Get name of a result item.
virtual bool Abort(void)=0
Abort the connection.
virtual void InitApplicationName(void)
Explicitly auto-initialize the application name, if necessary.
virtual Uint4 GetProtocolVersion(void) const =0
void SetChildObj(const CDBConnParams &child_obj) const
CDB_RPCCmd * RPC(const string &rpc_name, unsigned int)
virtual ~CParamStmt(void)
virtual bool Fetch(void)=0
Fetch next row.
virtual CDBParams & GetDefineParams(void)=0
Get meta-information about defined parameters.
virtual bool Refresh(void)=0
Reset the connection to the "ready" state (cancel all active commands)
virtual I_DriverContext::TConnectionMode ConnectMode(void) const =0
Get the bitmask for the connection mode (BCP, secure login, ...)
bool SetMaxTextImageSize(size_t n)
virtual CDBParams * SemiShallowClone(void) const =0
Yield a lightweight copy of these parameters, sharing representations for variable-length datatypes.
const CDBConnParams & m_Other
CDBConnParams(const CDBConnParams &other)
virtual bool HasFailed(void) const =0
virtual Uint4 GetHost(void) const =0
virtual bool Send(void)=0
Send command to the server.
virtual string GetServerName(void) const =0
virtual string GetHostName(void) const =0
Get host name.
virtual bool SetMaxBlobSize(size_t nof_bytes)=0
Set maximal size for BLOB data.
virtual void SetTimeout(size_t nof_secs)=0
Set connection timeout.
virtual void PopCntxMsgHandler(CDB_UserHandler *h)=0
Remove message handler "h" and all handlers above it in the stack.
virtual ~CDBConnParams(void)
virtual int RowCount(void) const =0
Get the number of rows affected by the command Special case: negative on error or if there is no way ...
virtual unsigned int GetLoginTimeout(void) const =0
Get login timeout.
const CDBConnParams * m_ChildObj
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...
virtual size_t ItemMaxSize(unsigned int item_num) const =0
Get size (in bytes) of a result item.
virtual void CloseUnusedConnections(const string &srv_name=kEmptyStr, const string &pool_name=kEmptyStr, unsigned int max_closings=kMax_UInt)=0
Close reusable deleted connections for specified server and/or pool.
virtual string GetDriverName(void) const =0
unsigned int GetPosition(void) const
virtual Uint2 GetPort(void) const =0
virtual I_ConnectionExtra & GetExtraFeatures(void)=0
Get interface for extra features that could be implemented in the driver.
virtual bool Delete(const string &table_name)=0
Delete the last fetched row.
ENameFormat GetFormat(void) const
virtual const CDB_Object * GetValue(const CDBParamVariant ¶m) const =0
Get value of column.
virtual int GetColumnNum(void) const =0
Return number of columns in the recordset.
virtual unsigned int NofConnections(const TSvrRef &svr_ref, const string &pool_name="") const =0
virtual CDB_Connection * MakeConnection(const CDBConnParams ¶ms)=0
Create connection object using Load Balancer / connection factory.
virtual void PopMsgHandler(CDB_UserHandler *h)=0
Remove the message handler (and all above it) from the stack.
virtual int RowCount(void) const =0
Get the number of fetched rows Special case: negative on error or if there is no way that this comman...
virtual const string & GetProcName(void) const =0
Get a name of the procedure.
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)=0
Read a result item body (for BLOB columns, mostly).
virtual bool Cancel(void)=0
Cancel the BCP command.
virtual bool More(const string &query_text)=0
Add more text to the language command.
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, EGetItem policy=eAppendLOB)=0
Get a result item (you can use either GetItem or ReadItem).
virtual I_BlobDescriptor * GetBlobDescriptor(void)=0
Get a descriptor for a BLOB column (for SendData).
virtual const CDBParams & GetDefineParams(void) const =0
Get meta-information about rows in resultset.
virtual string GetDatabaseName(void) const =0
virtual EDB_Type ItemDataType(unsigned int item_num) const =0
Get datatype of a result item.
EConnectionMode
Connection mode.
virtual bool SkipItem(void)=0
Skip result item.
virtual void PopDefConnMsgHandler(CDB_UserHandler *h)=0
Remove `per-connection' mess.
virtual bool WasCanceled(void) const =0
Implementation-specific.
virtual bool CompleteBatch(void)=0
Complete batch – to store all rows transferred by far in this batch into the table.
virtual void SetHostName(const string &host_name)=0
Set host name.
virtual void SetApplicationName(const string &app_name)=0
Set application name.
virtual CRef< IConnValidator > GetConnValidator(void) const =0
CDBConnParams & operator=(const CDBConnParams &other)
virtual bool SetTimeout(unsigned int nof_secs=0)=0
Set connection timeout.
virtual const string & Password(void) const =0
Get the password.
CDBConnParamsDelegate(const CDBConnParamsDelegate &other)
void ReleaseChildObj(void) const
virtual CDB_ResultProcessor * SetResultProcessor(CDB_ResultProcessor *rp)=0
Set new result-processor.
virtual void PushMsgHandler(CDB_UserHandler *h, EOwnership ownership=eNoOwnership)=0
Put the message handler into message handler stack.
virtual unsigned int GetIndex(const CDBParamVariant ¶m) const =0
virtual bool CompleteBCP(void)=0
Complete the BCP and store all rows transferred in last batch into the table.
virtual bool IsReusable(void) const =0
Check if this connection is a reusable one.
virtual const string & ServerName(void) const =0
Get the server name.
virtual bool UpdateBlob(unsigned int item_num, CDB_Stream &data, bool log_it=true)=0
virtual void SetRecompile(bool recompile=true)=0
Set the "recompile before execute" flag for the stored proc Implementation-specific.
virtual string GetUserName(void) const =0
virtual const string & UserName(void) const =0
Get the user user.
virtual EDirection GetDirection(const CDBParamVariant ¶m) const =0
Get parameter's direction (in/out/inout).
const string & GetName(void) const
virtual string GetParam(const string &key) const =0
Parameters, which are not listed above explicitly, should be retrieved via SetParam() method.
virtual CDB_SendDataCmd * SendDataCmd(unsigned int item_num, size_t size, bool log_it=true, bool discard_results=true)=0
Create send-data command.
virtual bool IsAbleTo(ECapability cpb) const =0
Check if a driver is acle to provide necessary functionality.
virtual unsigned int NofConnections(const string &srv_name="", const string &pool_name="") const =0
Return number of currently open connections in this context.
virtual EDB_ResType ResultType(void) const =0
Get type of the result.
virtual CDB_Result * Result(void)=0
Get result set.
#define NCBI_PARAM_DECL_EXPORT(expname, type, section, name)
Same as NCBI_PARAM_DECL but with export specifier (e.g.
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned short GetPort() const
Get the listening port number back.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
Uint4 GetHost(TEndpointKey key)
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
static PyObject * Connect(PyObject *self, PyObject *args, PyObject *kwargs)
const GenericPointer< typename T::ValueType > T2 value
Help distribute connections within a pool across servers.