backup command
This commit is contained in:
parent
fe5be1115b
commit
8ae7d5ad2d
@ -1,10 +1,12 @@
|
||||
import typer
|
||||
import httpx
|
||||
import lxml.html
|
||||
import sqlite3
|
||||
from typing_extensions import Annotated
|
||||
from .db import initialize_db
|
||||
from .tui.things import run as things_tui
|
||||
#from .tui.overview import run as overview_tui
|
||||
|
||||
# from .tui.overview import run as overview_tui
|
||||
from .tui.recurring import run as recurring_tui
|
||||
from .controller.things import add_thing
|
||||
|
||||
@ -40,6 +42,7 @@ def new(
|
||||
add_thing(name, category, due)
|
||||
typer.echo("Created new thing!")
|
||||
|
||||
|
||||
@app.command()
|
||||
def table(
|
||||
view: Annotated[str, typer.Option("-v", "--view", help="saved view")] = "default",
|
||||
@ -60,5 +63,23 @@ def overview():
|
||||
overview_tui()
|
||||
|
||||
|
||||
@app.command()
|
||||
def backup(backup_path: str):
|
||||
"""
|
||||
Perform a SQLite backup using the .backup dot command
|
||||
"""
|
||||
from tt.db import db
|
||||
|
||||
conn = db.connection()
|
||||
|
||||
backup_conn = None
|
||||
try:
|
||||
backup_conn = sqlite3.connect(backup_path)
|
||||
conn.backup(backup_conn)
|
||||
finally:
|
||||
if backup_conn:
|
||||
backup_conn.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
|
Loading…
Reference in New Issue
Block a user