|
| 1 | +# KGR Toolbox |
| 2 | + |
| 3 | +A QGIS plugin for managing PostgreSQL database templates and creating portable project archives. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +### 🗄️ PostgreSQL Template Management |
| 8 | +- **Create Templates**: Generate database templates from existing PostgreSQL databases without data |
| 9 | +- **Deploy Templates**: Create new databases from existing templates |
| 10 | +- **Schema Preservation**: Maintain all database structure, constraints, and relationships |
| 11 | + |
| 12 | +### 📦 Portable Project Archives |
| 13 | +- **PostgreSQL to Geopackage**: Convert all PostgreSQL layers to a single portable geopackage |
| 14 | +- **Complete Project Export**: Copy all project files including DCIM folders and media |
| 15 | +- **QField Compatible**: Create archives ready for mobile data collection with QField |
| 16 | +- **Progress Tracking**: Real-time progress feedback during export process |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +### From QGIS Plugin Repository |
| 21 | +1. Open QGIS |
| 22 | +2. Go to `Plugins` → `Manage and Install Plugins` |
| 23 | +3. Search for "KGR Toolbox" |
| 24 | +4. Click `Install Plugin` |
| 25 | + |
| 26 | +### Manual Installation |
| 27 | +1. Download the latest release from [GitHub Releases](https://github.com/csgis/postgresql-template-manager/releases) |
| 28 | +2. Extract the zip file to your QGIS plugins directory: |
| 29 | + - **Windows**: `C:\Users\[username]\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\` |
| 30 | + - **macOS**: `~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/` |
| 31 | + - **Linux**: `~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/` |
| 32 | +3. Restart QGIS |
| 33 | +4. Enable the plugin in `Plugins` → `Manage and Install Plugins` → `Installed` |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +### PostgreSQL Template Management |
| 38 | + |
| 39 | +#### Creating a Template |
| 40 | +1. Open the KGR Toolbox plugin |
| 41 | +2. Go to the **Database Connection** tab |
| 42 | +3. Enter your PostgreSQL connection details |
| 43 | +4. Click **Test Connection** |
| 44 | +5. Switch to the **Create Template** tab |
| 45 | +6. Select source database and enter template name |
| 46 | +7. Click **Create Template** |
| 47 | + |
| 48 | +#### Deploying from Template |
| 49 | +1. Ensure your connection is configured |
| 50 | +2. Go to the **Deploy Template** tab |
| 51 | +3. Select the template database |
| 52 | +4. Enter new database name |
| 53 | +5. Click **Deploy Database** |
| 54 | + |
| 55 | +### Creating Portable Archives |
| 56 | + |
| 57 | +#### Export Project Archive |
| 58 | +1. Open your QGIS project with PostgreSQL layers |
| 59 | +2. Open the KGR Toolbox plugin |
| 60 | +3. Go to the **Archive Project** tab |
| 61 | +4. Select output folder |
| 62 | +5. Click **Create Portable Archive** |
| 63 | + |
| 64 | +The plugin will: |
| 65 | +- Copy all project files and folders (including DCIM) |
| 66 | +- Convert all PostgreSQL layers to a single geopackage |
| 67 | +- Update the project file to use geopackage sources |
| 68 | +- Create a portable `_portable.qgs` file |
| 69 | + |
| 70 | +#### Warning |
| 71 | +The archive process copies ALL files from your project directory, including DCIM folders which may be quite large. Choose your output location carefully. |
| 72 | + |
| 73 | +## Requirements |
| 74 | + |
| 75 | +- QGIS 3.0 or higher |
| 76 | +- PostgreSQL database with appropriate permissions |
| 77 | +- Python 3.6+ (included with QGIS) |
| 78 | + |
| 79 | +## Supported Formats |
| 80 | + |
| 81 | +### Input |
| 82 | +- PostgreSQL databases |
| 83 | +- QGIS projects (.qgs files) |
| 84 | +- All standard QGIS vector layers |
| 85 | + |
| 86 | +### Output |
| 87 | +- PostgreSQL templates |
| 88 | +- Geopackage (.gpkg) |
| 89 | +- Portable QGIS projects |
| 90 | + |
| 91 | +## Technical Details |
| 92 | + |
1 | 93 | ### SQL Commands for Template Creation |
2 | 94 |
|
3 | 95 | When creating a clean template from a database, the plugin executes the following SQL commands in sequence: |
@@ -88,4 +180,58 @@ ORDER BY schemaname, tablename; |
88 | 180 |
|
89 | 181 | # 5. Truncate each table (repeat for each table found) |
90 | 182 | TRUNCATE TABLE "schema_name"."table_name" CASCADE; |
91 | | -``` |
| 183 | +``` |
| 184 | + |
| 185 | +## Use Cases |
| 186 | + |
| 187 | +### Template Management |
| 188 | +- **Development Workflows**: Create clean database templates for new projects |
| 189 | +- **Testing**: Deploy consistent test databases |
| 190 | +- **Team Collaboration**: Share database structures without sensitive data |
| 191 | +- **Backup & Recovery**: Maintain structural backups |
| 192 | + |
| 193 | +### Portable Archives |
| 194 | +- **Project Sharing**: Share projects without database dependencies |
| 195 | +- **Offline Work**: Convert online projects for offline use |
| 196 | +- **Data Distribution**: Package projects for easy distribution |
| 197 | + |
| 198 | + |
| 199 | +## Troubleshooting |
| 200 | + |
| 201 | +### Common Issues |
| 202 | + |
| 203 | +**Connection Failed** |
| 204 | +- Verify PostgreSQL server is running |
| 205 | +- Check host, port, and credentials |
| 206 | +- Ensure user has appropriate permissions |
| 207 | + |
| 208 | +**Template Creation Failed** |
| 209 | +- Ensure user has CREATEDB privileges |
| 210 | +- Check database name doesn't already exist |
| 211 | +- Verify sufficient disk space |
| 212 | + |
| 213 | +**Archive Export Failed** |
| 214 | +- Check write permissions in output folder |
| 215 | +- Ensure sufficient disk space |
| 216 | +- Verify QGIS project is saved |
| 217 | + |
| 218 | +### Getting Help |
| 219 | +- Check the [Issues](https://github.com/csgis/kgr_toolbox/issues) page |
| 220 | +- Create a new issue with detailed description |
| 221 | +- Include QGIS version, PostgreSQL version, and error messages |
| 222 | + |
| 223 | +## License |
| 224 | + |
| 225 | +This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](https://opensource.org/license/mit) file for details. |
| 226 | + |
| 227 | + |
| 228 | +## Changelog |
| 229 | + |
| 230 | +### v1.0.0 |
| 231 | +- Initial release |
| 232 | +- PostgreSQL template management |
| 233 | +- Portable project archive creation |
| 234 | +- QField compatibility |
| 235 | +- Progress tracking and user feedback |
| 236 | + |
| 237 | +--- |
0 commit comments