export: Allow exporting only the data in an SQL export · DelphiGit/sqlitebrowser@c8f0203 · GitHub
Skip to content

Commit c8f0203

Browse files
committed
export: Allow exporting only the data in an SQL export
In the SQL Export dialog and process, allow the user to export the data only, i.e. not the schema. See issue sqlitebrowser#556.
1 parent f46b800 commit c8f0203

4 files changed

Lines changed: 46 additions & 24 deletions

File tree

‎src/ExportSqlDialog.cpp‎

Lines changed: 7 additions & 1 deletion

‎src/ExportSqlDialog.ui‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,22 @@
110110
</spacer>
111111
</item>
112112
<item row="2" column="0">
113-
<widget class="QCheckBox" name="checkSchemaOnly">
114-
<property name="text">
115-
<string>Export schema only</string>
116-
</property>
113+
<widget class="QComboBox" name="comboWhat">
114+
<item>
115+
<property name="text">
116+
<string>Export everything</string>
117+
</property>
118+
</item>
119+
<item>
120+
<property name="text">
121+
<string>Export schema only</string>
122+
</property>
123+
</item>
124+
<item>
125+
<property name="text">
126+
<string>Export data only</string>
127+
</property>
128+
</item>
117129
</widget>
118130
</item>
119131
</layout>
@@ -135,8 +147,8 @@
135147
<slot>accept()</slot>
136148
<hints>
137149
<hint type="sourcelabel">
138-
<x>252</x>
139-
<y>136</y>
150+
<x>258</x>
151+
<y>331</y>
140152
</hint>
141153
<hint type="destinationlabel">
142154
<x>157</x>
@@ -151,8 +163,8 @@
151163
<slot>doDeselectAll()</slot>
152164
<hints>
153165
<hint type="sourcelabel">
154-
<x>20</x>
155-
<y>20</y>
166+
<x>298</x>
167+
<y>150</y>
156168
</hint>
157169
<hint type="destinationlabel">
158170
<x>20</x>
@@ -167,8 +179,8 @@
167179
<slot>doSelectAll()</slot>
168180
<hints>
169181
<hint type="sourcelabel">
170-
<x>20</x>
171-
<y>20</y>
182+
<x>80</x>
183+
<y>150</y>
172184
</hint>
173185
<hint type="destinationlabel">
174186
<x>20</x>

‎src/sqlitedb.cpp‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ bool DBBrowserDB::dump(const QString& filename,
420420
const QStringList & tablesToDump,
421421
bool insertColNames,
422422
bool insertNewSyntx,
423-
bool exportSchemaOnly)
423+
bool exportSchema,
424+
bool exportData)
424425
{
425426
// Open file
426427
QFile file(filename);
@@ -466,9 +467,11 @@ bool DBBrowserDB::dump(const QString& filename,
466467
continue;
467468

468469
// Write the SQL string used to create this table to the output file
469-
stream << it->getsql() << ";\n";
470+
if(exportSchema)
471+
stream << it->getsql() << ";\n";
470472

471-
if (exportSchemaOnly)
473+
// If the user doesn't want the data to be exported skip the rest of the loop block here
474+
if(!exportData)
472475
continue;
473476

474477
// get columns
@@ -557,17 +560,18 @@ bool DBBrowserDB::dump(const QString& filename,
557560
sqlite3_finalize(stmt);
558561
}
559562

560-
// Now dump all the other objects
561-
for(objectMap::ConstIterator it=objMap.begin();it!=objMap.end();++it)
563+
// Now dump all the other objects (but only if we are exporting the schema)
564+
if(exportSchema)
562565
{
563-
// Make sure it's not a table again
564-
if(it.value().gettype() == "table")
565-
continue;
566-
567-
// Write the SQL string used to create this object to the output file
568-
if(!it->getsql().isEmpty())
566+
for(objectMap::ConstIterator it=objMap.begin();it!=objMap.end();++it)
569567
{
570-
stream << it->getsql() << ";\n";
568+
// Make sure it's not a table again
569+
if(it.value().gettype() == "table")
570+
continue;
571+
572+
// Write the SQL string used to create this object to the output file
573+
if(!it->getsql().isEmpty())
574+
stream << it->getsql() << ";\n";
571575
}
572576
}
573577

‎src/sqlitedb.h‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)