Wrap commits in a transaction.
This commit is contained in:
parent
2e19a79772
commit
9f4f661eef
1 changed files with 4 additions and 0 deletions
|
|
@ -129,10 +129,14 @@ proc process( client: Socket, db: DBConn ): void =
|
||||||
return
|
return
|
||||||
|
|
||||||
var samples = parse_data( raw_data )
|
var samples = parse_data( raw_data )
|
||||||
|
if samples.len == 0: return
|
||||||
|
|
||||||
|
db.exec sql( "BEGIN" )
|
||||||
for timestamp, sample in samples:
|
for timestamp, sample in samples:
|
||||||
var host = sample[ "hostname" ].get_str
|
var host = sample[ "hostname" ].get_str
|
||||||
sample.delete( "hostname" )
|
sample.delete( "hostname" )
|
||||||
db.exec sql( INSERT_SQL ), timestamp, host, sample
|
db.exec sql( INSERT_SQL ), timestamp, host, sample
|
||||||
|
db.exec sql( "COMMIT" )
|
||||||
|
|
||||||
proc serverloop: void =
|
proc serverloop: void =
|
||||||
## Open a database connection, bind to the listening socket,
|
## Open a database connection, bind to the listening socket,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue