MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / exportQueryAsSQL

Function exportQueryAsSQL

frontend/src/utils/queryExport.ts:100–120  ·  view source on GitHub ↗
(
  query: string,
  filename: string = 'Query'
)

Source from the content-addressed store, hash-verified

98 * Export query as SQL file
99 */
100export const exportQueryAsSQL = (
101 query: string,
102 filename: string = 'Query'
103): void => {
104 try {
105 if (!query.trim()) {
106 throw new Error('No query to export');
107 }
108
109 const sqlContent = `-- DataKit SQL Query
110-- Generated on: ${new Date().toLocaleDateString()}
111
112${query}`;
113
114 downloadText(sqlContent, filename, 'sql');
115
116 } catch (error) {
117 console.error('Failed to export SQL:', error);
118 throw new Error('SQL export failed. Please try again.');
119 }
120};
121
122/**
123 * Generate HTML content for query results PDF

Callers 1

exportQueryFunction · 0.85

Calls 1

downloadTextFunction · 0.90

Tested by

no test coverage detected