Add preliminary documentation for database conversion
This commit is contained in:
parent
c19be34e71
commit
269630e755
@ -554,6 +554,27 @@ Show whitelist when using a [dynamic pairlist](plugins.md#pairlists).
|
||||
freqtrade test-pairlist --config config.json --quote USDT BTC
|
||||
```
|
||||
|
||||
## Convert database
|
||||
|
||||
`freqtrade convert-db` can be used to convert your database from one system to another (sqlite -> postgres, postgres -> other postgres), migrating all trades, orders and Pairlocks.
|
||||
|
||||
Please refer to the [SQL cheatsheet](sql_cheatsheet.md#use-a-different-database-system) to learn about requirements for different database systems.
|
||||
|
||||
```
|
||||
usage: freqtrade convert-db [-h] [--db-url PATH] [--db-url-from PATH]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
--db-url PATH Override trades database URL, this is useful in custom
|
||||
deployments (default: `sqlite:///tradesv3.sqlite` for
|
||||
Live Run mode, `sqlite:///tradesv3.dryrun.sqlite` for
|
||||
Dry Run).
|
||||
--db-url-from PATH Source db url to use when migrating database systems.
|
||||
```
|
||||
|
||||
!!! Warning
|
||||
Please ensure to only use this on an empty target database. Freqtrade will perform a regular migration, but may fail if entries already existed.
|
||||
|
||||
## Webserver mode
|
||||
|
||||
!!! Warning "Experimental"
|
||||
|
@ -10,7 +10,7 @@ from freqtrade.commands.arguments import Arguments
|
||||
from freqtrade.commands.build_config_commands import start_new_config
|
||||
from freqtrade.commands.data_commands import (start_convert_data, start_convert_trades,
|
||||
start_download_data, start_list_data)
|
||||
from freqtrade.commands.db_commands import start_db_convert
|
||||
from freqtrade.commands.db_commands import start_convert_db
|
||||
from freqtrade.commands.deploy_commands import (start_create_userdir, start_install_ui,
|
||||
start_new_strategy)
|
||||
from freqtrade.commands.hyperopt_commands import start_hyperopt_list, start_hyperopt_show
|
||||
|
@ -82,7 +82,7 @@ ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit",
|
||||
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
|
||||
"trade_source", "timeframe", "plot_auto_open", ]
|
||||
|
||||
ARGS_INSTALL_DB = ["db_url", "db_url_from"]
|
||||
ARGS_CONVERT_DB = ["db_url", "db_url_from"]
|
||||
|
||||
ARGS_INSTALL_UI = ["erase_ui_only", "ui_version"]
|
||||
|
||||
@ -183,15 +183,14 @@ class Arguments:
|
||||
self._build_args(optionlist=['version'], parser=self.parser)
|
||||
|
||||
from freqtrade.commands import (start_backtesting, start_backtesting_show,
|
||||
start_convert_data, start_convert_trades,
|
||||
start_create_userdir, start_db_convert, start_download_data,
|
||||
start_edge, start_hyperopt, start_hyperopt_list,
|
||||
start_hyperopt_show, start_install_ui, start_list_data,
|
||||
start_list_exchanges, start_list_markets,
|
||||
start_list_strategies, start_list_timeframes,
|
||||
start_new_config, start_new_strategy, start_plot_dataframe,
|
||||
start_plot_profit, start_show_trades, start_test_pairlist,
|
||||
start_trading, start_webserver)
|
||||
start_convert_data, start_convert_db, start_convert_trades,
|
||||
start_create_userdir, start_download_data, start_edge,
|
||||
start_hyperopt, start_hyperopt_list, start_hyperopt_show,
|
||||
start_install_ui, start_list_data, start_list_exchanges,
|
||||
start_list_markets, start_list_strategies,
|
||||
start_list_timeframes, start_new_config, start_new_strategy,
|
||||
start_plot_dataframe, start_plot_profit, start_show_trades,
|
||||
start_test_pairlist, start_trading, start_webserver)
|
||||
|
||||
subparsers = self.parser.add_subparsers(dest='command',
|
||||
# Use custom message when no subhandler is added
|
||||
@ -379,11 +378,11 @@ class Arguments:
|
||||
|
||||
# Add db-convert subcommand
|
||||
convert_db = subparsers.add_parser(
|
||||
"db-convert",
|
||||
"convert-db",
|
||||
help="Migrate database to different system",
|
||||
)
|
||||
convert_db.set_defaults(func=start_db_convert)
|
||||
self._build_args(optionlist=ARGS_INSTALL_DB, parser=convert_db)
|
||||
convert_db.set_defaults(func=start_convert_db)
|
||||
self._build_args(optionlist=ARGS_CONVERT_DB, parser=convert_db)
|
||||
|
||||
# Add install-ui subcommand
|
||||
install_ui_cmd = subparsers.add_parser(
|
||||
|
@ -8,7 +8,7 @@ from freqtrade.enums.runmode import RunMode
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def start_db_convert(args: Dict[str, Any]) -> None:
|
||||
def start_convert_db(args: Dict[str, Any]) -> None:
|
||||
from sqlalchemy.orm import make_transient
|
||||
|
||||
from freqtrade.persistence import Trade, init_db
|
||||
|
@ -14,7 +14,7 @@ from freqtrade.commands import (start_backtesting_show, start_convert_data, star
|
||||
start_list_exchanges, start_list_markets, start_list_strategies,
|
||||
start_list_timeframes, start_new_strategy, start_show_trades,
|
||||
start_test_pairlist, start_trading, start_webserver)
|
||||
from freqtrade.commands.db_commands import start_db_convert
|
||||
from freqtrade.commands.db_commands import start_convert_db
|
||||
from freqtrade.commands.deploy_commands import (clean_ui_subdir, download_and_install_ui,
|
||||
get_ui_download_url, read_ui_version)
|
||||
from freqtrade.configuration import setup_utils_configuration
|
||||
@ -1462,13 +1462,13 @@ def test_backtesting_show(mocker, testdatadir, capsys):
|
||||
assert "Pairs for Strategy" in out
|
||||
|
||||
|
||||
def test_start_db_convert(mocker, fee, tmpdir, caplog):
|
||||
def test_start_convert_db(mocker, fee, tmpdir, caplog):
|
||||
db_src_file = Path(f"{tmpdir}/db.sqlite")
|
||||
db_from = f"sqlite:///{db_src_file}"
|
||||
db_target_file = Path(f"{tmpdir}/db_target.sqlite")
|
||||
db_to = f"sqlite:///{db_target_file}"
|
||||
args = [
|
||||
"db-convert",
|
||||
"convert-db",
|
||||
"--db-url-from",
|
||||
db_from,
|
||||
"--db-url",
|
||||
@ -1483,5 +1483,5 @@ def test_start_db_convert(mocker, fee, tmpdir, caplog):
|
||||
assert not db_target_file.is_file()
|
||||
pargs = get_args(args)
|
||||
pargs['config'] = None
|
||||
start_db_convert(pargs)
|
||||
start_convert_db(pargs)
|
||||
assert db_target_file.is_file()
|
||||
|
Loading…
Reference in New Issue
Block a user