forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLite3Helper.java
More file actions
28 lines (21 loc) · 787 Bytes
/
SQLite3Helper.java
File metadata and controls
28 lines (21 loc) · 787 Bytes
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
package sqlancer.sqlite3;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import sqlancer.sqlite3.schema.SQLite3Schema;
import sqlancer.sqlite3.schema.SQLite3Schema.SQLite3Table;
public final class SQLite3Helper {
private SQLite3Helper() {
}
public static void dropTable(Connection con, SQLite3Table table) throws SQLException {
try (Statement s = con.createStatement()) {
s.execute("DROP TABLE IF EXISTS " + table.getName());
}
}
public static void deleteAllTables(Connection con) throws SQLException {
SQLite3Schema previousSchema = SQLite3Schema.fromConnection(con);
for (SQLite3Table t : previousSchema.getDatabaseTables()) {
dropTable(con, t);
}
}
}