Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Guix Cuirass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Panda
Guix Cuirass
Commits
18e42be3
Unverified
Commit
18e42be3
authored
8 years ago
by
Mathieu Lirzin
Browse files
Options
Downloads
Patches
Plain Diff
database: Use 'simple-format' in 'sqlite-exec'.
parent
adc624c7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cuirass/database.scm
+11
-13
11 additions, 13 deletions
src/cuirass/database.scm
with
11 additions
and
13 deletions
src/cuirass/database.scm
+
11
−
13
View file @
18e42be3
...
...
@@ -34,9 +34,12 @@
;; Macros.
with-database
))
(
define
(
sqlite-exec
db
sql
)
"Wrap 'sqlite-prepare', 'sqlite-step', and 'sqlite-finalize'."
(
let
((
stmt
(
sqlite-prepare
db
sql
)))
(
define
(
sqlite-exec
db
msg
.
args
)
"Wrap 'sqlite-prepare', 'sqlite-step', and 'sqlite-finalize'. Send message
MSG to database DB. MSG can contain '~A' and '~S' escape characters which
will be replaced by ARGS."
(
let*
((
sql
(
apply
simple-format
#f
msg
args
))
(
stmt
(
sqlite-prepare
db
sql
)))
(
sqlite-step
stmt
)
(
sqlite-finalize
stmt
)))
...
...
@@ -86,11 +89,9 @@ database object."
(
define
(
db-add-evaluation
db
job
)
"Store a derivation result in database DB and return its ID."
(
sqlite-exec
db
(
format
#f
"insert into build (job_spec, drv) values ('~A', '~A');"
(
assq-ref
job
#
:job-name
)
(
assq-ref
job
#
:derivation
)))
(
sqlite-exec
db
"insert into build (job_spec, drv) values ('~A', '~A');"
(
assq-ref
job
#
:job-name
)
(
assq-ref
job
#
:derivation
))
(
let*
((
stmt
(
sqlite-prepare
db
"select last_insert_rowid() from build;"
))
(
res
(
sqlite-step
stmt
)))
(
sqlite-finalize
stmt
)
...
...
@@ -107,8 +108,7 @@ database object."
(
define
(
db-delete-evaluation
db
id
)
"Delete a job in database DB which corresponds to ID."
(
sqlite-exec
db
(
format
#f
"delete from build where id=~A;"
id
)))
(
sqlite-exec
db
"delete from build where id=~A;"
id
))
(
define-syntax-rule
(
with-database
db
body
...
)
"Run BODY with a connection to the database which is bound to DB in BODY."
...
...
@@ -135,6 +135,4 @@ string."
(
seek
log
0
SEEK_SET
)
(
read-quoted-string
log
))
(
else
#f
))))
(
sqlite-exec
db
(
format
#f
"update build set log='~A' where id=~A;"
log*
id
))))
(
sqlite-exec
db
"update build set log='~A' where id=~A;"
log*
id
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment