db: tools for printing raw SQL instead of human readable info for the db
[smatch.git] / smatch_scripts / db / fill_db_sql.pl
blob5752d10b87f7a79381b4fe0178f85fb70dc26ddb
1 #!/usr/bin/perl -w
3 use strict;
4 use DBI;
6 my $warns = shift;
8 if (!defined($warns)) {
9 print "usage: $0 <warns.txt>\n";
10 exit(1);
13 my $db = DBI->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit => 0});
14 $db->do("PRAGMA synchronous = OFF");
15 $db->do("PRAGMA cache_size = 800000");
16 $db->do("PRAGMA journal_mode = OFF");
18 my ($dummy, $sql);
20 open(WARNS, "<$warns");
21 while (<WARNS>) {
23 if (!($_ =~ /^.*? \w+\(\) SQL: /)) {
24 next;
26 ($dummy, $dummy, $sql) = split(/:/);
28 $db->do($sql);
31 $db->commit();
32 $db->disconnect();