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
- Use parameterized queries
- Create indexes for performance
- Backup databases regularly
- Use transactions for data integrity
- Store ODB source files in version control
- Document database schema
- Use appropriate data types
- 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.
1---2name: base3description: Database management, forms, reports, and data operations with LibreOffice Base. 4category: Document Processing5source: antigravity6tags: [python, api, automation, workflow, template, design, document, spreadsheet]7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/libreoffice/base8metadata:9 source: https://skillmd.com/skills/sickn33/base10---111213# LibreOffice Base1415## Overview1617LibreOffice Base skill for creating, managing, and automating database workflows using the native ODB (OpenDocument Database) format.1819## When to Use This Skill2021Use this skill when:22- Creating new databases in ODB format23- Connecting to external databases (MySQL, PostgreSQL, etc.)24- Automating database operations and reports25- Creating forms and reports26- Building database applications2728## Core Capabilities2930### 1. Database Creation31- Create new ODB databases from scratch32- Design tables, views, and relationships33- Create embedded HSQLDB/Firebird databases34- Connect to external databases3536### 2. Data Operations37- Import data from CSV, spreadsheets38- Export data to various formats39- Query execution and management40- Batch data processing4142### 3. Form and Report Automation43- Create data entry forms44- Design custom reports45- Automate report generation46- Build form templates4748### 4. Query and SQL49- Visual query design50- SQL query execution51- Query optimization52- Result set manipulation5354### 5. Integration55- Command-line automation56- Python scripting with UNO57- JDBC/ODBC connectivity5859## Workflows6061### Creating a New Database6263#### Method 1: Command-Line64```bash65soffice --base66```6768#### Method 2: Python with UNO69```python70import uno7172def create_database():73 local_ctx = uno.getComponentContext()74 resolver = local_ctx.ServiceManager.createInstanceWithContext(75 "com.sun.star.bridge.UnoUrlResolver", local_ctx76 )77 ctx = resolver.resolve(78 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"79 )80 smgr = ctx.ServiceManager81 doc = smgr.createInstanceWithContext("com.sun.star.sdb.DatabaseDocument", ctx)82 doc.storeToURL("file:///path/to/database.odb", ())83 doc.close(True)84```8586### Connecting to External Database8788```python89import uno9091def connect_to_mysql(host, port, database, user, password):92 local_ctx = uno.getComponentContext()93 resolver = local_ctx.ServiceManager.createInstanceWithContext(94 "com.sun.star.bridge.UnoUrlResolver", local_ctx95 )96 ctx = resolver.resolve(97 "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"98 )99 smgr = ctx.ServiceManager100 101 doc = smgr.createInstanceWithContext("com.sun.star.sdb.DatabaseDocument", ctx)102 datasource = doc.getDataSource()103 datasource.URL = f"sdbc:mysql:jdbc:mysql://{host}:{port}/{database}"104 datasource.Properties["UserName"] = user105 datasource.Properties["Password"] = password106 107 doc.storeToURL("file:///path/to/connected.odb", ())108 return doc109```110111## Database Connection Reference112113### Supported Database Types114- HSQLDB (embedded)115- Firebird (embedded)116- MySQL/MariaDB117- PostgreSQL118- SQLite119- ODBC data sources120- JDBC data sources121122### Connection Strings123124```125# MySQL126sdbc:mysql:jdbc:mysql://localhost:3306/database127128# PostgreSQL129sdbc:postgresql://localhost:5432/database130131# SQLite132sdbc:sqlite:file:///path/to/database.db133134# ODBC135sdbc:odbc:DSN_NAME136```137138## Command-Line Reference139140```bash141soffice --headless142soffice --base # Base143```144145## Python Libraries146147```bash148pip install pyodbc # ODBC connectivity149pip install sqlalchemy # SQL toolkit150```151152## Best Practices1531541. Use parameterized queries1552. Create indexes for performance1563. Backup databases regularly1574. Use transactions for data integrity1585. Store ODB source files in version control1596. Document database schema1607. Use appropriate data types1618. Handle connection errors gracefully162163## Troubleshooting164165### Cannot open socket166```bash167killall soffice.bin168soffice --headless --accept="socket,host=localhost,port=8100;urp;"169```170171### Connection Issues172- Verify database server is running173- Check connection string format174- Ensure JDBC/ODBC drivers are installed175- Verify network connectivity176177## Resources178179- [LibreOffice Base Guide](https://documentation.libreoffice.org/)180- [UNO API Reference](https://api.libreoffice.org/)181- [HSQLDB Documentation](http://hsqldb.org/)182- [Firebird Documentation](https://firebirdsql.org/)183184## Related Skills185186- writer187- calc188- impress189- draw190- workflow-automation191192## Limitations193- Use this skill only when the task clearly matches the scope described above.194- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.195- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.