SQLite Database Editor

SQLite Database Editor
Query Results Report
SQL Command
Results
Initializing Database Engine...

Current Database Schema

Database File Management

Import SQLite File

Upload a .sqlite or .db file to replace the current database.

Click to Upload Database File

Export Current Database

Download the current state of the database as a file.

No tables found in database.

"; } } catch(e) { console.error("Schema refresh failed", e); } } // --- IO Functions --- function sdeExportDb() { if(!db) return; const binaryArray = db.export(); const blob = new Blob([binaryArray], {type: "application/x-sqlite3"}); const a = document.createElement('a'); a.href = window.URL.createObjectURL(blob); a.download = "database_export.sqlite"; a.click(); } function sdeHandleFileUpload(input) { const file = input.files[0]; if (!file) return; const r = new FileReader(); r.onload = function() { const uints = new Uint8Array(r.result); try { db = new SQL.Database(uints); // Reset UI document.getElementById('sde-sql-input').value = "SELECT name FROM sqlite_master WHERE type='table';"; sdeRunQuery(); // Run a basic query to show it worked sdeRefreshSchema(); alert("Database imported successfully."); sdeSwitchTab('query'); } catch(e) { alert("Error loading database file: " + e.message); } } r.readAsArrayBuffer(file); } // --- PDF Generation --- async function sdeDownloadPDF() { const { jsPDF } = window.jspdf; const element = document.getElementById('sde-tab-query'); element.classList.add('pdf-mode'); try { const canvas = await html2canvas(element, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4'); const imgWidth = 190; const imgHeight = canvas.height * imgWidth / canvas.width; pdf.setFontSize(10); pdf.text(`Report Generated: ${new Date().toLocaleString()}`, 10, 10); // If tall, add page logic could go here, but fitting to one page for tool spec simplicity pdf.addImage(imgData, 'PNG', 10, 15, imgWidth, imgHeight); pdf.save('SQL_Results.pdf'); } catch (err) { console.error("PDF Error", err); alert("Could not generate PDF."); } finally { element.classList.remove('pdf-mode'); } }
Scroll to Top