SQLite Forum

Feature request: add an optional transaction size in mode insert
Login
What you request can be readily achieved with ordinary scripting methods.

For example, this Perl script:

```
# /usr/bin/perl

my $nClump = shift;

if (!defined($nClump)) { $nClump = 100; }

print "BEGIN TRANSACTION;\n";

my $nLines = 0;

while ($_ = <>) {
  print $_;
  if (++$nLines % $nClump == 0) {
    print "COMMIT TRANSACTION;\n";
    print "BEGIN TRANSACTION;\n";
  }
}

print "COMMIT TRANSACTION;\n";
```

in a file marked executable, "transact_clump", can be used thusly:

```
echo .quit | sqlite3 -batch -cmd ".mode insert People" -cmd "select * from People;" furd.sdb | transact_clump 5
```

to break a long sequence of inserts into clumps of inserts within transactions.