hikyuu 2.1.0__cp38-none-win_amd64.whl → 2.1.2__cp38-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core38.pyd +0 -0
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/examples/notebook/006-TradeManager.ipynb +41 -39
- hikyuu/examples/notebook/008-Pickle.ipynb +27 -35
- hikyuu/extend.py +3 -1
- hikyuu/fetcher/stock/zh_stock_a_qmt.py +49 -0
- hikyuu/gui/HikyuuTDX.py +13 -7
- hikyuu/gui/data/MainWindow.py +126 -126
- hikyuu/gui/spot_server.py +16 -7
- hikyuu/gui/start_qmt.py +36 -0
- hikyuu/include/hikyuu/DataType.h +2 -1
- hikyuu/include/hikyuu/KRecord.h +1 -1
- hikyuu/include/hikyuu/Stock.h +1 -1
- hikyuu/include/hikyuu/StockManager.h +3 -0
- hikyuu/include/hikyuu/StrategyContext.h +7 -2
- hikyuu/include/hikyuu/analysis/combinate.h +1 -1
- hikyuu/include/hikyuu/config.h +0 -12
- hikyuu/include/hikyuu/data_driver/base_info/table/HistoryFinanceTable.h +2 -2
- hikyuu/include/hikyuu/doc.h +2 -2
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +1 -0
- hikyuu/include/hikyuu/global/GlobalTaskGroup.h +4 -2
- hikyuu/include/hikyuu/global/SpotRecord.h +52 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +14 -41
- hikyuu/include/hikyuu/hikyuu.h +1 -0
- hikyuu/include/hikyuu/strategy/{AccountTradeManager.h → BrokerTradeManager.h} +97 -95
- hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +36 -0
- hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +37 -0
- hikyuu/include/hikyuu/strategy/Strategy.h +174 -0
- hikyuu/include/hikyuu/trade_manage/FundsRecord.h +8 -8
- hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +66 -14
- hikyuu/include/hikyuu/trade_manage/PositionRecord.h +12 -12
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +9 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +19 -0
- hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
- hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
- hikyuu/include/hikyuu/{Log.h → utilities/Log.h} +91 -113
- hikyuu/include/hikyuu/utilities/Null.h +1 -0
- hikyuu/include/hikyuu/utilities/Parameter.h +2 -1
- hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
- hikyuu/include/hikyuu/utilities/SpendTimer.h +10 -9
- hikyuu/include/hikyuu/utilities/TimerManager.h +25 -11
- hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
- hikyuu/include/hikyuu/utilities/arithmetic.h +71 -35
- hikyuu/include/hikyuu/utilities/base64.h +59 -0
- hikyuu/include/hikyuu/utilities/config.h +41 -0
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +42 -31
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +24 -13
- hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +48 -48
- hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +10 -0
- hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +5 -22
- hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +3 -3
- hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +7 -7
- hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +1 -2
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +9 -9
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +18 -18
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +3 -3
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +2 -2
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +6 -6
- hikyuu/include/hikyuu/{exception.h → utilities/exception.h} +15 -16
- hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
- hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
- hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
- hikyuu/include/hikyuu/utilities/{IniParser.h → ini_parser/IniParser.h} +10 -5
- hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/md5.h +41 -0
- hikyuu/include/hikyuu/utilities/mo/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/mo/mo.h +48 -0
- hikyuu/include/hikyuu/utilities/mo/moFileReader.h +836 -0
- hikyuu/include/hikyuu/{global → utilities}/node/NodeClient.h +25 -18
- hikyuu/include/hikyuu/{global → utilities}/node/NodeError.h +1 -1
- hikyuu/include/hikyuu/{global → utilities}/node/NodeMessage.h +3 -2
- hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
- hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
- hikyuu/include/hikyuu/utilities/os.h +16 -15
- hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
- hikyuu/include/hikyuu/utilities/string_view.h +70 -0
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +3 -3
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +3 -3
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +3 -3
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +3 -3
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/interactive.py +42 -137
- hikyuu/sqlite3.dll +0 -0
- hikyuu/strategy/__init__.py +0 -1
- hikyuu/strategy/strategy_demo1.py +53 -0
- hikyuu/strategy/strategy_demo2.py +47 -0
- hikyuu/strategy/strategy_demo3.py +24 -0
- hikyuu/trade_manage/broker.py +27 -11
- hikyuu/trade_manage/broker_easytrader.py +52 -6
- hikyuu/trade_manage/broker_mail.py +17 -20
- hikyuu/vcruntime140.dll +0 -0
- hikyuu/vcruntime140_1.dll +0 -0
- hikyuu-2.1.2.dist-info/METADATA +115 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/RECORD +105 -79
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/top_level.txt +4 -2
- hikyuu/README.rst +0 -79
- hikyuu/include/hikyuu/strategy/StrategyBase.h +0 -156
- hikyuu/strategy/demo/__init__.py +0 -3
- hikyuu/strategy/strategy.py +0 -27
- hikyuu-2.1.0.dist-info/METADATA +0 -126
- /hikyuu/include/hikyuu/{global/node → utilities/http_client}/__init__.py +0 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/LICENSE +0 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/WHEEL +0 -0
- {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/entry_points.txt +0 -0
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
#ifndef HIKYUU_DB_CONNECT_DBCONNECTBASE_H
|
|
11
11
|
#define HIKYUU_DB_CONNECT_DBCONNECTBASE_H
|
|
12
12
|
|
|
13
|
-
#include "../../DataType.h"
|
|
14
13
|
#include "../../utilities/Parameter.h"
|
|
14
|
+
#include "../Null.h"
|
|
15
15
|
#include "DBCondition.h"
|
|
16
16
|
#include "SQLStatementBase.h"
|
|
17
17
|
#include "SQLException.h"
|
|
@@ -25,7 +25,7 @@ class SQLResultSet;
|
|
|
25
25
|
* 数据库连接基类
|
|
26
26
|
* @ingroup DBConnect
|
|
27
27
|
*/
|
|
28
|
-
class
|
|
28
|
+
class HKU_UTILS_API DBConnectBase : public std::enable_shared_from_this<DBConnectBase> {
|
|
29
29
|
PARAMETER_SUPPORT // NOSONAR
|
|
30
30
|
|
|
31
31
|
public :
|
|
@@ -297,7 +297,7 @@ private:
|
|
|
297
297
|
};
|
|
298
298
|
|
|
299
299
|
/** @ingroup DBConnect */
|
|
300
|
-
typedef shared_ptr<DBConnectBase> DBConnectPtr;
|
|
300
|
+
typedef std::shared_ptr<DBConnectBase> DBConnectPtr;
|
|
301
301
|
|
|
302
302
|
//-------------------------------------------------------------------------
|
|
303
303
|
// inline方法实现
|
|
@@ -366,19 +366,16 @@ void DBConnectBase::save(T &item, bool autotrans) {
|
|
|
366
366
|
if (autotrans) {
|
|
367
367
|
commit();
|
|
368
368
|
}
|
|
369
|
-
|
|
370
369
|
} catch (hku::SQLException &e) {
|
|
371
370
|
if (autotrans) {
|
|
372
371
|
rollback();
|
|
373
372
|
}
|
|
374
373
|
SQL_THROW(e.errcode(), "failed save! sql: {}! {}", st->getSqlString(), e.what());
|
|
375
|
-
|
|
376
374
|
} catch (std::exception &e) {
|
|
377
375
|
if (autotrans) {
|
|
378
376
|
rollback();
|
|
379
377
|
}
|
|
380
378
|
HKU_THROW("failed save! sql: {}! {}", st->getSqlString(), e.what());
|
|
381
|
-
|
|
382
379
|
} catch (...) {
|
|
383
380
|
if (autotrans) {
|
|
384
381
|
rollback();
|
|
@@ -409,19 +406,16 @@ void DBConnectBase::batchSave(InputIterator first, InputIterator last, bool auto
|
|
|
409
406
|
if (autotrans) {
|
|
410
407
|
commit();
|
|
411
408
|
}
|
|
412
|
-
|
|
413
409
|
} catch (hku::SQLException &e) {
|
|
414
410
|
if (autotrans) {
|
|
415
411
|
rollback();
|
|
416
412
|
}
|
|
417
413
|
SQL_THROW(e.errcode(), "failed batch save! sql: {}! {}", st->getSqlString(), e.what());
|
|
418
|
-
|
|
419
414
|
} catch (std::exception &e) {
|
|
420
415
|
if (autotrans) {
|
|
421
416
|
rollback();
|
|
422
417
|
}
|
|
423
418
|
HKU_THROW("failed batch save! sql: {}! {}", st->getSqlString(), e.what());
|
|
424
|
-
|
|
425
419
|
} catch (...) {
|
|
426
420
|
if (autotrans) {
|
|
427
421
|
rollback();
|
|
@@ -431,7 +425,7 @@ void DBConnectBase::batchSave(InputIterator first, InputIterator last, bool auto
|
|
|
431
425
|
}
|
|
432
426
|
|
|
433
427
|
template <typename T>
|
|
434
|
-
void DBConnectBase::load(T &item, const string &where) {
|
|
428
|
+
void DBConnectBase::load(T &item, const std::string &where) {
|
|
435
429
|
std::ostringstream sql;
|
|
436
430
|
if (where != "") {
|
|
437
431
|
sql << T::getSelectSQL() << " where " << where << " limit 1";
|
|
@@ -451,7 +445,7 @@ void DBConnectBase::load(T &item, const DBCondition &cond) {
|
|
|
451
445
|
}
|
|
452
446
|
|
|
453
447
|
template <typename Container>
|
|
454
|
-
void DBConnectBase::batchLoad(Container &container, const string &where) {
|
|
448
|
+
void DBConnectBase::batchLoad(Container &container, const std::string &where) {
|
|
455
449
|
std::ostringstream sql;
|
|
456
450
|
if (where != "") {
|
|
457
451
|
sql << Container::value_type::getSelectSQL() << " where " << where;
|
|
@@ -513,19 +507,16 @@ void DBConnectBase::batchUpdate(InputIterator first, InputIterator last, bool au
|
|
|
513
507
|
if (autotrans) {
|
|
514
508
|
commit();
|
|
515
509
|
}
|
|
516
|
-
|
|
517
510
|
} catch (hku::SQLException &e) {
|
|
518
511
|
if (autotrans) {
|
|
519
512
|
rollback();
|
|
520
513
|
}
|
|
521
514
|
SQL_THROW(e.errcode(), "failed batch save! sql: {}! {}", st->getSqlString(), e.what());
|
|
522
|
-
|
|
523
515
|
} catch (std::exception &e) {
|
|
524
516
|
if (autotrans) {
|
|
525
517
|
rollback();
|
|
526
518
|
}
|
|
527
519
|
HKU_THROW("failed batch update! sql: {}! {}", st->getSqlString(), e.what());
|
|
528
|
-
|
|
529
520
|
} catch (...) {
|
|
530
521
|
if (autotrans) {
|
|
531
522
|
rollback();
|
|
@@ -570,19 +561,16 @@ void DBConnectBase::remove(T &item, bool autotrans) {
|
|
|
570
561
|
commit();
|
|
571
562
|
}
|
|
572
563
|
item.rowid(0);
|
|
573
|
-
|
|
574
564
|
} catch (hku::SQLException &e) {
|
|
575
565
|
if (autotrans) {
|
|
576
566
|
rollback();
|
|
577
567
|
}
|
|
578
568
|
SQL_THROW(e.errcode(), "failed delete! sql: {}! {}", st->getSqlString(), e.what());
|
|
579
|
-
|
|
580
569
|
} catch (std::exception &e) {
|
|
581
570
|
if (autotrans) {
|
|
582
571
|
rollback();
|
|
583
572
|
}
|
|
584
573
|
HKU_THROW("failed delete! sql: {}! {}", st->getSqlString(), e.what());
|
|
585
|
-
|
|
586
574
|
} catch (...) {
|
|
587
575
|
if (autotrans) {
|
|
588
576
|
rollback();
|
|
@@ -610,19 +598,16 @@ void DBConnectBase::batchRemove(InputIterator first, InputIterator last, bool au
|
|
|
610
598
|
if (autotrans) {
|
|
611
599
|
commit();
|
|
612
600
|
}
|
|
613
|
-
|
|
614
601
|
} catch (hku::SQLException &e) {
|
|
615
602
|
if (autotrans) {
|
|
616
603
|
rollback();
|
|
617
604
|
}
|
|
618
605
|
SQL_THROW(e.errcode(), "failed batch delete! {}", e.what());
|
|
619
|
-
|
|
620
606
|
} catch (std::exception &e) {
|
|
621
607
|
if (autotrans) {
|
|
622
608
|
rollback();
|
|
623
609
|
}
|
|
624
610
|
HKU_THROW("failed batch delete! {}", e.what());
|
|
625
|
-
|
|
626
611
|
} catch (...) {
|
|
627
612
|
if (autotrans) {
|
|
628
613
|
rollback();
|
|
@@ -645,13 +630,11 @@ inline void DBConnectBase::remove(const std::string &tablename, const std::strin
|
|
|
645
630
|
if (autotrans) {
|
|
646
631
|
commit();
|
|
647
632
|
}
|
|
648
|
-
|
|
649
633
|
} catch (hku::SQLException &e) {
|
|
650
634
|
if (autotrans) {
|
|
651
635
|
rollback();
|
|
652
636
|
}
|
|
653
637
|
SQL_THROW(e.errcode(), "Failed exec sql: {}! {}", sql, e.what());
|
|
654
|
-
|
|
655
638
|
} catch (std::exception &e) {
|
|
656
639
|
if (autotrans) {
|
|
657
640
|
rollback();
|
|
@@ -21,8 +21,8 @@ namespace hku {
|
|
|
21
21
|
* @param create_script 数据库创建脚本,若对应的数据库不存在则使用该脚本创建数据库
|
|
22
22
|
* @ingroup DataDriver
|
|
23
23
|
*/
|
|
24
|
-
void
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
void HKU_UTILS_API DBUpgrade(const DBConnectPtr &driver, const char *module_name,
|
|
25
|
+
const std::vector<std::string> &upgrade_scripts, int start_version = 2,
|
|
26
|
+
const char *create_script = nullptr);
|
|
27
27
|
|
|
28
28
|
} // namespace hku
|
|
@@ -21,7 +21,7 @@ namespace hku {
|
|
|
21
21
|
class DBConnectBase;
|
|
22
22
|
|
|
23
23
|
/** @ingroup DBConnect */
|
|
24
|
-
typedef shared_ptr<DBConnectBase> DBConnectPtr;
|
|
24
|
+
typedef std::shared_ptr<DBConnectBase> DBConnectPtr;
|
|
25
25
|
|
|
26
26
|
/** @ingroup DBConnect */
|
|
27
27
|
class null_blob_exception : public exception {
|
|
@@ -34,19 +34,19 @@ public:
|
|
|
34
34
|
* SQL Statement 基类
|
|
35
35
|
* @ingroup DBConnect
|
|
36
36
|
*/
|
|
37
|
-
class
|
|
37
|
+
class HKU_UTILS_API SQLStatementBase {
|
|
38
38
|
public:
|
|
39
39
|
/**
|
|
40
40
|
* 构造函数
|
|
41
41
|
* @param driver 数据库连接
|
|
42
42
|
* @param sql_statement SQL语句
|
|
43
43
|
*/
|
|
44
|
-
SQLStatementBase(DBConnectBase *driver, const string &sql_statement);
|
|
44
|
+
SQLStatementBase(DBConnectBase *driver, const std::string &sql_statement);
|
|
45
45
|
|
|
46
46
|
virtual ~SQLStatementBase() = default;
|
|
47
47
|
|
|
48
48
|
/** 获取构建时传入的表达式SQL语句 */
|
|
49
|
-
const string &getSqlString() const;
|
|
49
|
+
const std::string &getSqlString() const;
|
|
50
50
|
|
|
51
51
|
/** 获取数据驱动 */
|
|
52
52
|
DBConnectBase *getConnect() const;
|
|
@@ -163,7 +163,7 @@ protected:
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
/** @ingroup DBConnect */
|
|
166
|
-
typedef shared_ptr<SQLStatementBase> SQLStatementPtr;
|
|
166
|
+
typedef std::shared_ptr<SQLStatementBase> SQLStatementPtr;
|
|
167
167
|
|
|
168
168
|
inline SQLStatementBase ::SQLStatementBase(DBConnectBase *driver, const std::string &sql_statement)
|
|
169
169
|
: m_driver(driver), m_sql_string(sql_statement) {
|
|
@@ -183,7 +183,7 @@ inline void SQLStatementBase::bind(int idx, float item) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
inline void SQLStatementBase::exec() {
|
|
186
|
-
#
|
|
186
|
+
#if HKU_SQL_TRACE
|
|
187
187
|
HKU_DEBUG(m_sql_string);
|
|
188
188
|
#endif
|
|
189
189
|
sub_exec();
|
|
@@ -277,7 +277,7 @@ inline void SQLStatementBase::getColumn(int idx, std::vector<char> &item) {
|
|
|
277
277
|
template <typename T>
|
|
278
278
|
typename std::enable_if<!std::numeric_limits<T>::is_integer>::type SQLStatementBase::getColumn(
|
|
279
279
|
int idx, T &item) {
|
|
280
|
-
string tmp;
|
|
280
|
+
std::string tmp;
|
|
281
281
|
try {
|
|
282
282
|
sub_getColumnAsBlob(idx, tmp);
|
|
283
283
|
} catch (null_blob_exception &) {
|
|
@@ -2168,8 +2168,7 @@ public:
|
|
|
2168
2168
|
}
|
|
2169
2169
|
|
|
2170
2170
|
#define TABLE_NO_AUTOID_BIND12(ROWID, table, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) \
|
|
2171
|
-
pprivate:
|
|
2172
|
-
uint64_t m_rowid = 0; \
|
|
2171
|
+
pprivate : uint64_t m_rowid = 0; \
|
|
2173
2172
|
\
|
|
2174
2173
|
public: \
|
|
2175
2174
|
bool valid() const { \
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
|
|
23
23
|
namespace hku {
|
|
24
24
|
|
|
25
|
-
class
|
|
25
|
+
class HKU_UTILS_API MySQLConnect : public DBConnectBase {
|
|
26
26
|
public:
|
|
27
|
-
explicit MySQLConnect(const Parameter&
|
|
27
|
+
explicit MySQLConnect(const Parameter ¶m);
|
|
28
28
|
virtual ~MySQLConnect();
|
|
29
29
|
|
|
30
|
-
MySQLConnect(const MySQLConnect&) = delete;
|
|
31
|
-
MySQLConnect&
|
|
30
|
+
MySQLConnect(const MySQLConnect &) = delete;
|
|
31
|
+
MySQLConnect &operator=(const MySQLConnect &) = delete;
|
|
32
32
|
|
|
33
33
|
virtual bool ping() override;
|
|
34
34
|
|
|
35
|
-
virtual int64_t exec(const std::string&
|
|
36
|
-
virtual SQLStatementPtr getStatement(const std::string&
|
|
37
|
-
virtual bool tableExist(const std::string&
|
|
38
|
-
virtual void resetAutoIncrement(const std::string&
|
|
35
|
+
virtual int64_t exec(const std::string &sql_string) override;
|
|
36
|
+
virtual SQLStatementPtr getStatement(const std::string &sql_statement) override;
|
|
37
|
+
virtual bool tableExist(const std::string &tablename) override;
|
|
38
|
+
virtual void resetAutoIncrement(const std::string &tablename) override;
|
|
39
39
|
|
|
40
40
|
virtual void transaction() noexcept override;
|
|
41
41
|
virtual void commit() noexcept override;
|
|
@@ -48,7 +48,7 @@ private:
|
|
|
48
48
|
|
|
49
49
|
private:
|
|
50
50
|
friend class MySQLStatement;
|
|
51
|
-
MYSQL*
|
|
51
|
+
MYSQL *m_mysql;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
} // namespace hku
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
typedef bool my_bool;
|
|
27
27
|
#endif
|
|
28
28
|
|
|
29
|
-
#ifndef
|
|
30
|
-
#define
|
|
29
|
+
#ifndef HKU_UTILS_API
|
|
30
|
+
#define HKU_UTILS_API
|
|
31
31
|
#endif
|
|
32
32
|
|
|
33
33
|
namespace hku {
|
|
34
34
|
|
|
35
|
-
class
|
|
35
|
+
class HKU_UTILS_API MySQLStatement : public SQLStatementBase {
|
|
36
36
|
public:
|
|
37
37
|
MySQLStatement() = delete;
|
|
38
|
-
MySQLStatement(DBConnectBase*
|
|
38
|
+
MySQLStatement(DBConnectBase *driver, const std::string &sql_statement);
|
|
39
39
|
virtual ~MySQLStatement();
|
|
40
40
|
|
|
41
41
|
virtual void sub_exec() override;
|
|
@@ -45,28 +45,28 @@ public:
|
|
|
45
45
|
virtual void sub_bindNull(int idx) override;
|
|
46
46
|
virtual void sub_bindInt(int idx, int64_t value) override;
|
|
47
47
|
virtual void sub_bindDouble(int idx, double item) override;
|
|
48
|
-
virtual void sub_bindDatetime(int idx, const Datetime&
|
|
49
|
-
virtual void sub_bindText(int idx, const std::string&
|
|
50
|
-
virtual void sub_bindText(int idx, const char*
|
|
51
|
-
virtual void sub_bindBlob(int idx, const std::string&
|
|
52
|
-
virtual void sub_bindBlob(int idx, const std::vector<char
|
|
48
|
+
virtual void sub_bindDatetime(int idx, const Datetime &item) override;
|
|
49
|
+
virtual void sub_bindText(int idx, const std::string &item) override;
|
|
50
|
+
virtual void sub_bindText(int idx, const char *item, size_t len) override;
|
|
51
|
+
virtual void sub_bindBlob(int idx, const std::string &item) override;
|
|
52
|
+
virtual void sub_bindBlob(int idx, const std::vector<char> &item) override;
|
|
53
53
|
|
|
54
54
|
virtual int sub_getNumColumns() const override;
|
|
55
|
-
virtual void sub_getColumnAsInt64(int idx, int64_t&
|
|
56
|
-
virtual void sub_getColumnAsDouble(int idx, double&
|
|
57
|
-
virtual void sub_getColumnAsDatetime(int idx, Datetime&
|
|
58
|
-
virtual void sub_getColumnAsText(int idx, std::string&
|
|
59
|
-
virtual void sub_getColumnAsBlob(int idx, std::string&
|
|
60
|
-
virtual void sub_getColumnAsBlob(int idx, std::vector<char
|
|
55
|
+
virtual void sub_getColumnAsInt64(int idx, int64_t &item) override;
|
|
56
|
+
virtual void sub_getColumnAsDouble(int idx, double &item) override;
|
|
57
|
+
virtual void sub_getColumnAsDatetime(int idx, Datetime &item) override;
|
|
58
|
+
virtual void sub_getColumnAsText(int idx, std::string &item) override;
|
|
59
|
+
virtual void sub_getColumnAsBlob(int idx, std::string &item) override;
|
|
60
|
+
virtual void sub_getColumnAsBlob(int idx, std::vector<char> &item) override;
|
|
61
61
|
|
|
62
62
|
private:
|
|
63
63
|
void _reset();
|
|
64
64
|
void _bindResult();
|
|
65
65
|
|
|
66
66
|
private:
|
|
67
|
-
MYSQL*
|
|
68
|
-
MYSQL_STMT*
|
|
69
|
-
MYSQL_RES*
|
|
67
|
+
MYSQL *m_db;
|
|
68
|
+
MYSQL_STMT *m_stmt;
|
|
69
|
+
MYSQL_RES *m_meta_result;
|
|
70
70
|
bool m_needs_reset;
|
|
71
71
|
bool m_has_bind_result;
|
|
72
72
|
std::vector<MYSQL_BIND> m_param_bind;
|
|
@@ -25,7 +25,7 @@ namespace hku {
|
|
|
25
25
|
* SQLite连接
|
|
26
26
|
* @ingroup SQLite
|
|
27
27
|
*/
|
|
28
|
-
class
|
|
28
|
+
class HKU_UTILS_API SQLiteConnect : public DBConnectBase {
|
|
29
29
|
public:
|
|
30
30
|
/**
|
|
31
31
|
* 构造函数
|
|
@@ -78,11 +78,11 @@ private:
|
|
|
78
78
|
|
|
79
79
|
private:
|
|
80
80
|
friend class SQLiteStatement;
|
|
81
|
-
string m_dbname;
|
|
81
|
+
std::string m_dbname;
|
|
82
82
|
sqlite3 *m_db;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
typedef shared_ptr<SQLiteConnect> SQLiteConnectPtr;
|
|
85
|
+
typedef std::shared_ptr<SQLiteConnect> SQLiteConnectPtr;
|
|
86
86
|
|
|
87
87
|
} // namespace hku
|
|
88
88
|
|
|
@@ -19,7 +19,7 @@ namespace hku {
|
|
|
19
19
|
* SQLite Statemen
|
|
20
20
|
* @ingroup DBConnect
|
|
21
21
|
*/
|
|
22
|
-
class
|
|
22
|
+
class HKU_UTILS_API SQLiteStatement : public SQLStatementBase {
|
|
23
23
|
public:
|
|
24
24
|
SQLiteStatement() = delete;
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ public:
|
|
|
28
28
|
* @param driver 数据库连接
|
|
29
29
|
* @param sql_statement SQL语句
|
|
30
30
|
*/
|
|
31
|
-
SQLiteStatement(DBConnectBase *driver, const string &sql_statement);
|
|
31
|
+
SQLiteStatement(DBConnectBase *driver, const std::string &sql_statement);
|
|
32
32
|
|
|
33
33
|
/** 析构函数 */
|
|
34
34
|
virtual ~SQLiteStatement();
|
|
@@ -15,7 +15,7 @@ namespace hku {
|
|
|
15
15
|
* @brief SQLite 其他相关操作方法集合
|
|
16
16
|
* @ingroup DBConnect
|
|
17
17
|
*/
|
|
18
|
-
class
|
|
18
|
+
class HKU_UTILS_API SQLiteUtil {
|
|
19
19
|
public:
|
|
20
20
|
SQLiteUtil() = default;
|
|
21
21
|
~SQLiteUtil() = default;
|
|
@@ -43,8 +43,8 @@ public:
|
|
|
43
43
|
* @param n_page 分批备份时每次循环备份的 page 数,小于等于0时,一次性备份,不进行分批备份
|
|
44
44
|
* @param step_sleep 分批备份时每次循环后,休眠间隔时长(毫秒),以便让出cpu
|
|
45
45
|
*/
|
|
46
|
-
static BackupResult onlineBackup(const std::shared_ptr<SQLiteConnect
|
|
47
|
-
const std::string&
|
|
46
|
+
static BackupResult onlineBackup(const std::shared_ptr<SQLiteConnect> &conn,
|
|
47
|
+
const std::string &dst, int n_page = -1,
|
|
48
48
|
int step_sleep = 250) noexcept;
|
|
49
49
|
/**
|
|
50
50
|
* @brief 在线备份数据库,不影响其他数据库连接进行操作
|
|
@@ -53,7 +53,7 @@ public:
|
|
|
53
53
|
* @param n_page 分批备份时每次循环备份的 page 数,小于等于0时,一次性备份,不进行分批备份
|
|
54
54
|
* @param step_sleep 分批备份时每次循环后,休眠间隔时长(毫秒),以便让出cpu
|
|
55
55
|
*/
|
|
56
|
-
static BackupResult onlineBackup(const std::string&
|
|
56
|
+
static BackupResult onlineBackup(const std::string &src, const std::string &dst,
|
|
57
57
|
int n_page = -1, int step_sleep = 250) noexcept;
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -65,7 +65,7 @@ public:
|
|
|
65
65
|
* @param save_bad 是否保存损坏的数据,将 dst 及 dst-journal 加上后缀 .bad 另存
|
|
66
66
|
* @return RecoverResult
|
|
67
67
|
*/
|
|
68
|
-
static RecoverResult recoverFromBackup(const std::string&
|
|
68
|
+
static RecoverResult recoverFromBackup(const std::string &backup, const std::string &dst,
|
|
69
69
|
bool save_bad = false) noexcept;
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -74,7 +74,7 @@ public:
|
|
|
74
74
|
* @return true 指定的数据库文件及其日志文件都被成功删除或都不存在时,返回成功
|
|
75
75
|
* @return false 指定的数据文件及其日志文件,其中一个删除失败都会返回删除失败
|
|
76
76
|
*/
|
|
77
|
-
static bool removeDBFile(const std::string&
|
|
77
|
+
static bool removeDBFile(const std::string &dbfilename);
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
} // namespace hku
|
|
@@ -14,39 +14,38 @@
|
|
|
14
14
|
#include <string>
|
|
15
15
|
#include <exception>
|
|
16
16
|
|
|
17
|
+
#ifndef HKU_UTILS_API
|
|
18
|
+
#define HKU_UTILS_API
|
|
19
|
+
#endif
|
|
20
|
+
|
|
17
21
|
namespace hku {
|
|
18
22
|
|
|
23
|
+
#if defined(_MSC_VER)
|
|
24
|
+
#pragma warning(push)
|
|
25
|
+
#pragma warning(disable : 4275)
|
|
26
|
+
#endif
|
|
27
|
+
|
|
19
28
|
/**
|
|
20
29
|
* @ingroup Utilities
|
|
21
30
|
* @addtogroup Exception Exception 异常处理
|
|
22
31
|
* @{
|
|
23
32
|
*/
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
class exception : public std::exception {
|
|
27
|
-
public:
|
|
28
|
-
exception() : std::exception("Unknown exception!") {}
|
|
29
|
-
exception(const std::string& msg) // cppcheck-suppress noExplicitConstructor
|
|
30
|
-
: std::exception(msg.c_str()) {}
|
|
31
|
-
exception(const char* msg) : std::exception(msg) {} // cppcheck-suppress noExplicitConstructor
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
#else
|
|
35
|
-
// llvm 中的 std::exception 不接受参数
|
|
36
|
-
class exception : public std::exception {
|
|
34
|
+
class HKU_UTILS_API exception : public std::exception {
|
|
37
35
|
public:
|
|
38
36
|
exception() : m_msg("Unknown exception!") {}
|
|
39
37
|
exception(const char *msg) : m_msg(msg) {} // cppcheck-suppress noExplicitConstructor
|
|
40
38
|
exception(const std::string &msg) : m_msg(msg) {} // cppcheck-suppress noExplicitConstructor
|
|
41
39
|
virtual ~exception() noexcept {}
|
|
42
|
-
virtual const char *what() const noexcept
|
|
43
|
-
return m_msg.c_str();
|
|
44
|
-
}
|
|
40
|
+
virtual const char *what() const noexcept;
|
|
45
41
|
|
|
46
42
|
protected:
|
|
47
43
|
std::string m_msg;
|
|
48
44
|
};
|
|
49
|
-
|
|
45
|
+
|
|
46
|
+
#if defined(_MSC_VER)
|
|
47
|
+
#pragma warning(pop)
|
|
48
|
+
#endif
|
|
50
49
|
|
|
51
50
|
} /* namespace hku */
|
|
52
51
|
|