Sign inSign up

big3/sql2xlsx

By big3

•Updated over 3 years ago

Выгрузка произвольного sql-запроса к Postgres в XLSX-документ

Image
0

43

big3/sql2xlsx repository overview

⁠Sql2xlsx выгрузка произвольного sql-запроса в XLSX-документ

Позволяет выгрузить результат запроса к БД Postgres в документ xlsx по шаблону или без него.

⁠Использование из командной строки:

Обязательных опций нет. Если опция не указна, то берется значение из .env или по-умолчанию.

Usage of ./sql2xlsx:
  -dsn string
        DSN database connection (default "postgres://app:@postgres:5432/app")
  -serve
        Start server
  -start_col int
        Start col number (default 1)
  -start_row int
        Start row number (default 1)
  -xlsx_result string
        Result, xlsx file (required if not --serve)
  -xlsx_template string
        Template, xlsx file

Пример:

echo "select * from users" | ./sql2xlsx \
    --dsn="postgres://app:[email protected]:5433/app" \
    --xlsx_result=users.xlsx \
    

⁠Запуск сервера

./sql2xlsx --serve \
    --dsn="postgres://app:[email protected]:5433/app"
openapi: '3.0.0'

info:
  version: 1.0.0
  title: SQL2XLSX Server

paths:
  '/':
    post:
      tags:
        - Выгрузка данных
      description: Выгрузка результата sql-запроса в xlsx-документ
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                dsn:
                  required: false
                  title: DSN
                  description: DSN подключения
                  example: postgres://app:@postgres:5432/app
                sql:
                  title: SQL
                  required: false
                  description: Запрос для выполнения
                  example: SELECT * FROM users
                xlsx_result:
                  title: Результат
                  required: true
                  description: Путь к файлу xlsx результата
                  example: /app/storage/result.xlsx
                xlsx_template:
                  title: Шаблон
                  required: false
                  description: Путь к файлу xlsx шаблона
                  example: /app/storage/template.xlsx
                start_col:
                  title: Колонка
                  required: false
                  description: Номер начальной колонки
                  minimum: 1
                  example: 1
                start_row:
                  title: Строка
                  required: false
                  description: Номер начальной строки
                  minimum: 1
                  example: 1

      operationId: export
      responses:
        200:
          description: Информация о результате экспорта
          content:
            application/json:
              schema:
                properties:
                  code:
                    type: integer
                    required: true
                    example: 200
                  message:
                    type: string
                    required: true
                    example: OK
                  data:
                    type: object
                    properties:
                      file:
                        type: string
                        required: true
                        example: "path/to/file.xlsx"
                      rows_count:
                        type: integer
                        required: true
                        example: 10

Tag summary

Content type

Image

Digest

sha256:e13faefb9…

Size

76.9 MB

Last updated

over 3 years ago

docker pull big3/sql2xlsx:master