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
|
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
|
## Webserver mode
|
||||||
|
|
||||||
!!! Warning "Experimental"
|
!!! 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.build_config_commands import start_new_config
|
||||||
from freqtrade.commands.data_commands import (start_convert_data, start_convert_trades,
|
from freqtrade.commands.data_commands import (start_convert_data, start_convert_trades,
|
||||||
start_download_data, start_list_data)
|
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,
|
from freqtrade.commands.deploy_commands import (start_create_userdir, start_install_ui,
|
||||||
start_new_strategy)
|
start_new_strategy)
|
||||||
from freqtrade.commands.hyperopt_commands import start_hyperopt_list, start_hyperopt_show
|
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",
|
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
|
||||||
"trade_source", "timeframe", "plot_auto_open", ]
|
"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"]
|
ARGS_INSTALL_UI = ["erase_ui_only", "ui_version"]
|
||||||
|
|
||||||
@ -183,15 +183,14 @@ class Arguments:
|
|||||||
self._build_args(optionlist=['version'], parser=self.parser)
|
self._build_args(optionlist=['version'], parser=self.parser)
|
||||||
|
|
||||||
from freqtrade.commands import (start_backtesting, start_backtesting_show,
|
from freqtrade.commands import (start_backtesting, start_backtesting_show,
|
||||||
start_convert_data, start_convert_trades,
|
start_convert_data, start_convert_db, start_convert_trades,
|
||||||
start_create_userdir, start_db_convert, start_download_data,
|
start_create_userdir, start_download_data, start_edge,
|
||||||
start_edge, start_hyperopt, start_hyperopt_list,
|
start_hyperopt, start_hyperopt_list, start_hyperopt_show,
|
||||||
start_hyperopt_show, start_install_ui, start_list_data,
|
start_install_ui, start_list_data, start_list_exchanges,
|
||||||
start_list_exchanges, start_list_markets,
|
start_list_markets, start_list_strategies,
|
||||||
start_list_strategies, start_list_timeframes,
|
start_list_timeframes, start_new_config, start_new_strategy,
|
||||||
start_new_config, start_new_strategy, start_plot_dataframe,
|
start_plot_dataframe, start_plot_profit, start_show_trades,
|
||||||
start_plot_profit, start_show_trades, start_test_pairlist,
|
start_test_pairlist, start_trading, start_webserver)
|
||||||
start_trading, start_webserver)
|
|
||||||
|
|
||||||
subparsers = self.parser.add_subparsers(dest='command',
|
subparsers = self.parser.add_subparsers(dest='command',
|
||||||
# Use custom message when no subhandler is added
|
# Use custom message when no subhandler is added
|
||||||
@ -379,11 +378,11 @@ class Arguments:
|
|||||||
|
|
||||||
# Add db-convert subcommand
|
# Add db-convert subcommand
|
||||||
convert_db = subparsers.add_parser(
|
convert_db = subparsers.add_parser(
|
||||||
"db-convert",
|
"convert-db",
|
||||||
help="Migrate database to different system",
|
help="Migrate database to different system",
|
||||||
)
|
)
|
||||||
convert_db.set_defaults(func=start_db_convert)
|
convert_db.set_defaults(func=start_convert_db)
|
||||||
self._build_args(optionlist=ARGS_INSTALL_DB, parser=convert_db)
|
self._build_args(optionlist=ARGS_CONVERT_DB, parser=convert_db)
|
||||||
|
|
||||||
# Add install-ui subcommand
|
# Add install-ui subcommand
|
||||||
install_ui_cmd = subparsers.add_parser(
|
install_ui_cmd = subparsers.add_parser(
|
||||||
|
@ -8,7 +8,7 @@ from freqtrade.enums.runmode import RunMode
|
|||||||
logger = logging.getLogger(__name__)
|
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 sqlalchemy.orm import make_transient
|
||||||
|
|
||||||
from freqtrade.persistence import Trade, init_db
|
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_exchanges, start_list_markets, start_list_strategies,
|
||||||
start_list_timeframes, start_new_strategy, start_show_trades,
|
start_list_timeframes, start_new_strategy, start_show_trades,
|
||||||
start_test_pairlist, start_trading, start_webserver)
|
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,
|
from freqtrade.commands.deploy_commands import (clean_ui_subdir, download_and_install_ui,
|
||||||
get_ui_download_url, read_ui_version)
|
get_ui_download_url, read_ui_version)
|
||||||
from freqtrade.configuration import setup_utils_configuration
|
from freqtrade.configuration import setup_utils_configuration
|
||||||
@ -1462,13 +1462,13 @@ def test_backtesting_show(mocker, testdatadir, capsys):
|
|||||||
assert "Pairs for Strategy" in out
|
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_src_file = Path(f"{tmpdir}/db.sqlite")
|
||||||
db_from = f"sqlite:///{db_src_file}"
|
db_from = f"sqlite:///{db_src_file}"
|
||||||
db_target_file = Path(f"{tmpdir}/db_target.sqlite")
|
db_target_file = Path(f"{tmpdir}/db_target.sqlite")
|
||||||
db_to = f"sqlite:///{db_target_file}"
|
db_to = f"sqlite:///{db_target_file}"
|
||||||
args = [
|
args = [
|
||||||
"db-convert",
|
"convert-db",
|
||||||
"--db-url-from",
|
"--db-url-from",
|
||||||
db_from,
|
db_from,
|
||||||
"--db-url",
|
"--db-url",
|
||||||
@ -1483,5 +1483,5 @@ def test_start_db_convert(mocker, fee, tmpdir, caplog):
|
|||||||
assert not db_target_file.is_file()
|
assert not db_target_file.is_file()
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_db_convert(pargs)
|
start_convert_db(pargs)
|
||||||
assert db_target_file.is_file()
|
assert db_target_file.is_file()
|
||||||
|
Loading…
Reference in New Issue
Block a user