跳到主要内容
知仓学习社ZHICANG

base

Database management, forms, reports, and data operations with LibreOffice Base.

不碰外部(只输出文字)无严重或高危命中sickn33/agentic-awesome-skills

它会碰到什么

扫了多少1 个文本文件,5 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

LibreOffice Base

Overview

LibreOffice Base skill for creating, managing, and automating database workflows using the native ODB (OpenDocument Database) format.

When to Use This Skill

Use this skill when:

  • Creating new databases in ODB format
  • Connecting to external databases (MySQL, PostgreSQL, etc.)
  • Automating database operations and reports
  • Creating forms and reports
  • Building database applications

Core Capabilities

1. Database Creation

  • Create new ODB databases from scratch
  • Design tables, views, and relationships
  • Create embedded HSQLDB/Firebird databases
  • Connect to external databases

2. Data Operations

  • Import data from CSV, spreadsheets
  • Export data to various formats
  • Query execution and management
  • Batch data processing

3. Form and Report Automation

  • Create data entry forms
  • Design custom reports
  • Automate report generation
  • Build form templates

4. Query and SQL

  • Visual query design
  • SQL query execution
  • Query optimization
  • Result set manipulation

5. Integration

  • Command-line automation
  • Python scripting with UNO
  • JDBC/ODBC connectivity

Workflows

Creating a New Database

Method 1: Command-Line

soffice --base

Method 2: Python with UNO

import uno

def create_database():
    local_ctx = uno.getComponentContext()
    resolver = local_ctx.ServiceManager.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", local_ctx
    )
    ctx = resolver.resolve(
        "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"
    )
    smgr = ctx.ServiceManager
    doc = smgr.createInstanceWithContext("com.sun.star.sdb.DatabaseDocument", ctx)
    doc.storeToURL("file:///path/to/database.odb", ())
    doc.close(True)

Connecting to External Database

import uno

def connect_to_mysql(host, port, database, user, password):
    local_ctx = uno.getComponentContext()
    resolver = local_ctx.ServiceManager.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", local_ctx
    )
    ctx = resolver.resolve(
        "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"
    )
    smgr = ctx.ServiceManager
    
    doc = smgr.createInstanceWithContext("com.sun.star.sdb.DatabaseDocument", ctx)
    datasource = doc.getDataSource()
    datasource.URL = f"sdbc:mysql:jdbc:mysql://{host}:{port}/{database}"
    datasource.Properties["UserName"] = user
    datasource.Properties["Password"] = password
    
    doc.storeToURL("file:///path/to/connected.odb", ())
    return doc

Database Connection Reference

Supported Database Types

  • HSQLDB (embedded)
  • Firebird (embedded)
  • MySQL/MariaDB
  • PostgreSQL
  • SQLite
  • ODBC data sources
  • JDBC data sources

Connection Strings

# MySQL
sdbc:mysql:jdbc:mysql://localhost:3306/database

# PostgreSQL
sdbc:postgresql://localhost:5432/database

# SQLite
sdbc:sqlite:file:///path/to/database.db

# ODBC
sdbc:odbc:DSN_NAME

Command-Line Reference

soffice --headless
soffice --base  # Base

Python Libraries

pip install pyodbc    # ODBC connectivity
pip install sqlalchemy # SQL toolkit

Best Practices

  1. Use parameterized queries
  2. Create indexes for performance
  3. Backup databases regularly
  4. Use transactions for data integrity
  5. Store ODB source files in version control
  6. Document database schema
  7. Use appropriate data types
  8. Handle connection errors gracefully

Troubleshooting

Cannot open socket

killall soffice.bin
soffice --headless --accept="socket,host=localhost,port=8100;urp;"

Connection Issues

  • Verify database server is running
  • Check connection string format
  • Ensure JDBC/ODBC drivers are installed
  • Verify network connectivity

Resources

Related Skills

  • writer
  • calc
  • impress
  • draw
  • workflow-automation

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

同名技能的其他版本

有 3 个不同仓库或目录里都有叫 base 的技能。它们内容并不相同,别混用: