cronodump/templates/postgres.j2
Yevhenii Kutsenko bd10fad70a Initial commit
2024-12-28 15:35:05 +03:00

21 lines
656 B
Django/Jinja

{% for table in db.enumerate_tables(files=False) %}
CREATE TABLE "{{ table.tablename | replace('"', '_') }}" (
{%- for field in table.fields %}
"{{ field.name | replace('"', '_') }}" {{ field.sqltype() -}}
{{- ", " if not loop.last else "" -}}
{%- endfor %}
);
INSERT INTO "{{ table.tablename | replace('"', '_') }}" VALUES
{%- for record in db.enumerate_records( table ) %}
( {%- for field in record.fields -%}
'{{ field.content | replace("'", "''") }}' {{- ", " if not loop.last else "" -}}
{%- endfor -%}
)
{{- ", " if not loop.last else "" -}}
{%- endfor %}
;
{% endfor %}