-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql2csv.html
More file actions
158 lines (144 loc) · 6.96 KB
/
Copy pathsql2csv.html
File metadata and controls
158 lines (144 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sql2csv - csvkit+</title>
<script>
(function () {
var saved = localStorage.getItem('theme');
document.documentElement.setAttribute('data-theme', saved === 'light' ? 'light' : 'dark');
})();
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:wght@400;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=VT323&display=block">
<link rel="stylesheet" href="src/style.css">
</head>
<body class="op-page">
<main class="wrap">
<a class="back-link" href="index.html">← Back</a>
<header class="intro">
<h1 class="title">sql2csv</h1>
<p class="lead">Run a SQL query against a connected database and save the results as a CSV.</p>
<button type="button" class="info-toggle" id="info-toggle">Show info</button>
<p class="lead" id="dialect-info" hidden>In <span class="accent-text">sql2csv</span> you can connect to <span class="accent-text">PostgreSQL</span>, <span class="accent-text">MySQL</span>, <span class="accent-text">CockroachDB</span>, and <span class="accent-text">MariaDB</span> databases - that should cover most users out there.</p>
</header>
<script>
(function () {
var toggle = document.getElementById('info-toggle');
var info = document.getElementById('dialect-info');
toggle.addEventListener('click', function () {
var hidden = info.hasAttribute('hidden');
if (hidden) {
info.removeAttribute('hidden');
toggle.textContent = 'Hide info';
} else {
info.setAttribute('hidden', '');
toggle.textContent = 'Show info';
}
});
})();
</script>
<div class="field-row">
<label class="field-label" for="connect-dialect-select">Database type</label>
<select class="select-input" id="connect-dialect-select">
<option value="postgresql">PostgreSQL</option>
<option value="cockroachdb">CockroachDB</option>
<option value="mysql">MySQL</option>
<option value="mariadb">MariaDB</option>
</select>
</div>
<div class="db-connect" id="db-connect">
<div class="field-row">
<label class="field-label" for="db-select">Database</label>
<select class="select-input" id="db-select"></select>
</div>
<div class="db-status-row hidden" id="db-status-row">
<span class="db-status-text" id="db-status-text">Connected to database</span>
<button class="clear-btn" type="button" id="db-rename-btn">Rename</button>
<button class="clear-btn" type="button" id="db-remove-btn">Remove</button>
<button class="run-btn" type="button" id="browse-tables-btn">Browse tables</button>
</div>
<div class="save-box db-form" id="db-rename-box">
<label class="field-label" for="db-rename-input">Name</label>
<input class="text-input" type="text" id="db-rename-input">
<div class="save-box-actions">
<button class="run-btn" type="button" id="db-rename-confirm">Save</button>
<button class="run-btn" type="button" id="db-rename-cancel">Cancel</button>
</div>
</div>
<div class="save-box db-form" id="db-form">
<label class="field-label" for="db-name-input">Name (optional)</label>
<input class="text-input" type="text" id="db-name-input" placeholder="My database">
<label class="field-label" for="db-connstr-input">Connection string</label>
<input class="text-input" type="text" id="db-connstr-input" placeholder="postgresql://user:pass@host/dbname">
<div class="save-box-actions">
<button class="run-btn" type="button" id="db-form-confirm">Connect</button>
<button class="run-btn" type="button" id="db-form-cancel">Cancel</button>
</div>
</div>
<div class="save-box db-confirm" id="db-remove-confirm">
<p class="lead">Remove this saved connection?</p>
<div class="save-box-actions">
<button class="run-btn" type="button" id="db-remove-yes">Remove</button>
<button class="run-btn" type="button" id="db-remove-no">Cancel</button>
</div>
</div>
</div>
<div class="schema-panel" id="schema-panel"></div>
<div class="save-box insert-confirm" id="insert-query-confirm">
<p class="lead" id="insert-query-label">Insert query for this table?</p>
<div class="save-box-actions">
<button class="run-btn" type="button" id="insert-query-stack">Stack</button>
<button class="run-btn" type="button" id="insert-query-replace">Replace</button>
<button class="run-btn" type="button" id="insert-query-cancel">Cancel</button>
</div>
</div>
<div class="stack-panel hidden" id="stack-panel">
<div class="file-chip-list" id="stack-chip-list"></div>
<div class="save-box-actions">
<button class="run-btn" type="button" id="run-stack-btn">Run stack</button>
<button class="clear-btn" type="button" id="clear-stack-btn">Clear stack</button>
</div>
</div>
<div class="options-panel visible" id="options-panel">
<div class="field-row">
<label class="field-label" for="query-input">SQL query</label>
<textarea class="text-input textarea-input" id="query-input" placeholder="SELECT * FROM my_table;"></textarea>
</div>
<button class="run-btn" type="button" id="run-btn">Run query</button>
</div>
<section class="output-area" id="output-area" aria-live="polite"></section>
<div class="action-row">
<div class="save-row" id="save-row">
<button class="save-btn" type="button" id="save-btn">Save</button>
</div>
<button class="clear-btn" type="button" id="clear-btn">Clear</button>
</div>
<div class="save-box" id="save-box">
<label class="field-label" for="save-filename">Filename</label>
<input class="text-input" type="text" id="save-filename" value="new.csv">
<div class="save-box-actions">
<button class="run-btn" type="button" id="save-confirm">Download</button>
<button class="run-btn" type="button" id="save-cancel">Cancel</button>
</div>
</div>
<div class="terminal" id="terminal"></div>
</main>
<footer class="site-footer">
<button class="foot-link" type="button" data-action="about">About</button>
<button class="foot-link" type="button" data-action="donate">Donate</button>
<button class="foot-link theme-toggle" type="button" id="theme-toggle" aria-pressed="false">
Theme
<span class="switch" aria-hidden="true">
<span class="switch-track">
<span class="switch-lever"></span>
</span>
</span>
</button>
</footer>
<script type="module" src="src/script.js"></script>
<script type="module" src="src/sql2csv.js"></script>
</body>
</html>