from typing import Union
import pathlib
from typing import Tuple
from typing import Optional
import sqlite3


def export_db_get_version(
    dbfile: Union[str, pathlib.Path]
) -> Tuple[Optional[int], Optional[int]]:
    """returns version from export database as tuple of (osxphotos version, export_db version)"""
    conn = sqlite3.connect(str(dbfile))
    c = conn.cursor()
    row = c.execute(
        "SELECT osxphotos, exportdb FROM version ORDER BY id DESC LIMIT 1;"
    ).fetchone()
    if row:
        return (row[0], row[1])
    return (None, None)