10 #ifndef litesql_backend_hpp
11 #define litesql_backend_hpp
15 #include "litesql/commontypes.h"
59 virtual std::string getSQLType(AT_field_type fieldType,
const std::string& length=
"")
const;
60 virtual std::string getCreateSequenceSQL(
const std::string& name)
const;
61 virtual std::string getSeqSQL(
const std::string& sname)
const;
66 return "INTEGER PRIMARY KEY";
97 const std::string& sequence)
const;
103 static std::unique_ptr<Backend>
getBackend(
const std::string& type,
const std::string& connInfo) noexcept(
false);
An abstract base class for cursors that iterate result sets returned by relational database.
Definition: backend.hpp:24
virtual ~Cursor()
empty
Definition: backend.hpp:27
virtual void setCacheSize(int)
if inherited Cursor can cache its data to speed up iteration, this method is used to set cache size.
Definition: backend.hpp:32
virtual Record fetchOne()=0
returns one result row.
Definition: backend.hpp:37
virtual size_t recordNum() const =0
returns number of rows (records) in result set
virtual size_t fieldNum() const =0
returns number of columns (fields) in result set
virtual Record fields() const =0
returns names of columns (fields) of the result set
virtual ~Result()
empty
Definition: backend.hpp:40
virtual Records records() const =0
returns result set
An abstract base class for interfacing with relational databases.
Definition: backend.hpp:20
virtual Cursor * cursor(const std::string &query) const =0
executes SQL-query
virtual ~Backend()
empty
Definition: backend.hpp:52
virtual void rollback() const
rollback SQL transaction
Definition: backend.hpp:77
virtual bool supportsSequences() const
return true if backend supports CREATE SEQUENCE - SQL-statements
Definition: backend.hpp:55
virtual std::string getInsertID() const
if backend supports this, new primary key of the last insert is returned
Definition: backend.hpp:71
virtual std::string groupInsert(const Record &tables, const Records &fields, const Records &values, const std::string &sequence) const
executes multiple INSERT-statements and assigns same 'row id' for first field of every record
Definition: backend.cpp:74
virtual void begin() const
begin SQL transaction, may or may not have an effect
Definition: backend.hpp:73
static std::unique_ptr< Backend > getBackend(const std::string &type, const std::string &connInfo) noexcept(false)
returns a backend according to Backendtype in type, parameters are specific to backend and are separa...
Definition: backend.cpp:205
virtual Result * execute(const std::string &query) const =0
executes SQL-query
virtual std::string getRowIDType() const
backend may want to set an AUTO_INCREMENT-attribute for table's primary key field.
Definition: backend.hpp:65
virtual void commit() const
commit SQL transaction
Definition: backend.hpp:75
SQL data row wrapper.
Definition: types.hpp:20
contains class Record and typedef Records
std::vector< Record > Records
shortcut
Definition: types.hpp:26