{# The modals of DATABASES: a lint finding, a slice, what a use of the code reaches, and those of Connections. `details`: everything about one connection (the card shows only its kind and server), in the consultation modal; with `editing`, its settings become the form's fields. Its actions sit in the modal's footer (sent out of band, as an entity's page does); they answer in the modal, the card following; Delete asks first, over the modal, then the page comes back and the modal closes. Without `details`: a new connection, in the notes' modal, posted to /databases/save. The details also show what was last read from the connection's database: the server reads it by itself while the connection is allowed; Refresh, in the footer, reads it again now. Every field is the wiki's form field (macros.form_field): ? with its explanation, outlined, * if required. #} {% import "macros.html" as ui %} {% from "database.html" import card %} {% set HELP = { "Name": "The name this connection is shown by, in DATABASES and to the agents. Only for you to recognise it; it changes nothing in the connection.", "Kind": "The kind of database. It decides the driver doctracker uses (pg8000, PyMySQL, python-tds, Python's sqlite3, oracledb) and how the session is made read only.", "Host": "The database server's name or address (for SQLite, the file's path, from the project's root). When the connection goes through SSH, it is the server as the SSH server sees it, e.g. a name inside its network. Any value may be ${VARIABLE} or ${VARIABLE:-default}, read from the environment and the project's .env files when connecting.", "Port": "The database server's port. Empty: the kind's usual one (PostgreSQL 5432, MySQL 3306, SQL Server 1433, Oracle 1521). May be ${VARIABLE}.", "Server": "Address and port of the database server. Any value may be ${VARIABLE} or ${VARIABLE:-default}, read from the environment and the project's .env files when connecting.", "File": "The SQLite file, from the project's root. It is opened read only.", "Database": "Name of the database on the server. Empty: every database the user can see on the server is read (each one doctracker can connect to).", "User": "The user doctracker connects as. A read-only user is best; whatever the user may do, doctracker only reads. May be ${VARIABLE}.", "Password": "The user's password. Typed here, it is saved encrypted in doc/connections/ (out of git), the key kept in your system's vault; or write ${VARIABLE} to take it from an environment variable. Never shown afterwards: once saved, empty keeps it. Not asked with AWS RDS IAM, whose token takes its place.", "SSH host": "An SSH server to go through: doctracker logs in to it and reaches the database from there. Empty: no tunnel, straight to the database.", "SSH port": "The SSH server's port. Empty: 22.", "SSH user": "The user on the SSH server. Empty: taken from ~/.ssh/config when that is ticked.", "Key file": "The private key to log in to the SSH server, e.g. ~/.ssh/id_ed25519 (a path from the project's root, or absolute). Empty: the password below, or your SSH agent's keys.", "SSH password": "The SSH user's password, or, when there is a key file, the key's passphrase. Saved encrypted like the database password, or ${VARIABLE}. Empty keeps the one saved.", "Jump host": "An SSH server reached first, to get to the SSH server above (a bastion): user@host:port. Empty: none.", "~/.ssh/config": "Ticked: whatever is not typed here (host name, port, user, key, jump host) comes from your ~/.ssh/config, by the SSH host's name.", "Sign-in": "How doctracker signs in: with the password, or with an AWS RDS IAM token made for this server and user (it needs doctracker's extra: pip install doctracker[aws]).", "AWS region": "Only for AWS RDS IAM: the region of the database, e.g. us-east-1. Empty: the one AWS's own settings give.", "SSH": "An SSH server the connection goes through: doctracker logs in to it, with a key or a password, and reaches the database from there. A jump host is reached first. With ~/.ssh/config, what is not typed comes from your SSH settings.", "URL in": "The environment variable holding the whole connection URL, read when connecting.", "From": "Where the connection is declared (file and line), or that it was entered here.", "Database read": "What doctracker read from the database's catalog, read only: every schema of the connection's database, with its tables, views, columns, keys, indexes, functions, triggers, comments and statistics, and the relations between them. Read by itself while the connection is allowed (when allowed, when doctracker starts, and every minute); Refresh reads it again now. Only this last reading is kept. What could not be read (permissions, statistics never gathered) is listed, never guessed. With no database named, every database on the server is read; with one named, the others on the same server are only listed.", "Last test": "The last test, read only: connect, read the server's version, try a write that must be aborted before it reaches the database; with when it ran and how long it took.", } %} {# A name in the details (not a form), with the ? explaining it. #} {% macro label(name) -%}
This finding is no longer found: the lint was read again.
{% endif %} {% elif reaches_mode %} {# What one use of a code entity reaches (its Database use's Reaches), in the consultation modal: the use itself, then the places holding the table or column, the live databases apart from the files. #} {% if link %}{{ link.where }}{{ link.evidence }}| {{ "Database" if group == "live" else "File" }} | Object |
|---|---|
{{ p.where }} | {{ p.object }} |
None.
{% endif %} {% endcall %} {% endfor %} {% else %}This use is no longer found: the code was read again.
{% endif %} {% elif diff_profile_mode %} {# A comparison of DATABASES › Diff kept as a profile, in doc/diff/: its name, what it is for and what it leaves out; A and B are the comparison shown in Trails. A saved one is changed in place (`previous`). #} {% set p = profile %} {% set chosen_ignore = form.ignore if form.ignore is defined else (p.ignore if p else []) %} {% if details %} {# Its details, in the consultation modal: everything it keeps and what its comparison finds now. #}{{ p.a }}{{ p.b }}{{ error }}
{% endif %}Compares {{ a.removeprefix("db:").removeprefix("origin:") }} with {{ b.removeprefix("db:").removeprefix("origin:") }}.
{{ error }}
{% endif %} {% if s %}{% endif %} {% call ui.form_field("Name", SLICE_HELP["Name"], required=True) %}{% endcall %} {% call ui.form_field("Text", SLICE_HELP["Text"]) %}{% endcall %} {% call ui.form_field("Tables", SLICE_HELP["Tables"], required=True, choice=True) %}| Table | Where | Found |
|---|---|---|
{% if t.found %}{{ t.key }}{% else %}{{ t.key }}{% endif %} |
{% if t.found %}{{ t.found.split("::")[0] if "::" in t.found else "/".join(t.found.split("/")[:2]) }}{% else %}-{% endif %} |
{% if t.found_by == "path" %}where it was taken from{% elif t.found_by == "name" %}by its name (taken from {{ t.path }}){% else %}not found{% endif %} |
{{ error }}
{% endif %} {% if editing %} {% else %}{{ c.host }}{{ c.host or "—" }}{% if c.port %}:{{ c.port }}{% endif %}{{ c.database }}{% else %}—{% endif %}{{ c.user }}{% else %}—{% endif %}{{ c.password or "none" }}{% if c.ssh_user %}{{ c.ssh_user }}@{% endif %}{{ c.ssh_host }}:{{ c.ssh_port or 22 }}{% if c.ssh_jump %} via {{ c.ssh_jump }}{% endif %}{% if c.ssh_key %} · key {{ c.ssh_key }}{% endif %}{% if c.ssh_password %} · {{ c.ssh_password }}{% endif %}{% if c.ssh_config %} · ~/.ssh/config{% endif %}
{% else %}none: straight to the server{% endif %}{{ c.sign_in_option }}{% endif %}${{ "{" }}{{ c.url_variable }}{{ "}" }}{{ c.origin }}{% if c.edited %} · changed here{% endif %}{% endif %}{{ k.database }}{% else %}every database{% endif %} on {{ k.server }} · {{ k.started | local_time(seconds=True) }} ({{ k.seconds }} s)
{{ name }}{% if not loop.last %}, {% endif %}{% endfor %}