FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/modules/dasSQLITE/tutorial/08-read_image.das at master · frodiwe/daScript · GitHub
frodiwe
/
daScript
Public
forked from
GaijinEntertainment/daScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
daScript
/
modules
/
dasSQLITE
/
tutorial
/
08-read_image.das
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (37 loc) · 1.08 KB
Breadcrumbs
daScript
/
modules
/
dasSQLITE
/
tutorial
/
08-read_image.das
Copy path
File metadata and controls
40 lines (37 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
29
30
31
32
33
34
35
36
37
38
39
options
gen2
// based on https://zetcode.com/db/sqlitec/
require
sqlite
/
sqlite_boost
require
daslib
/
fio
[
export
]
def
main
{
var
db
:
sqlite3
?
var
rc
=
sqlite3_open
(
"test.db"
,
unsafe
(
addr
(
db
)))
if
(
rc
!
=
SQLITE_OK
) {
to_log
(
LOG_ERROR
,
"Cannot open database: sqlite3_errmsg(db)
\n
"
)
sqlite3_close
(
db
)
return
}
var
res
:
sqlite3_stmt
?
rc
=
sqlite3_prepare_v2
(
db
,
"SELECT Data FROM Images WHERE Id = 1"
,
-
1
,
unsafe
(
addr
(
res
)),
null
)
if
(
rc
!
=
SQLITE_OK
) {
to_log
(
LOG_ERROR
,
"Failed to prepare statement:
{
sqlite3_errmsg
(
db
)
}
\n
"
)
sqlite3_close
(
db
)
return
}
rc
=
sqlite3_step
(
res
)
if
(
rc
!
=
SQLITE_ROW
) {
to_log
(
LOG_ERROR
,
"Failed to step:
{
sqlite3_errmsg
(
db
)
}
\n
"
)
sqlite3_close
(
db
)
return
}
let
bytes
=
sqlite3_column_bytes
(
res
,
0
)
fopen
(
"test.png"
,
"wb"
)
$
(f) {
if
(
f
!
=
null
) {
f
|
>
_builtin_write
(
sqlite3_column_blob
(
res
,
0
),
bytes
)
}
else
{
panic
(
"can't open image.png"
)
}
}
sqlite3_finalize
(
res
)
sqlite3_close
(
db
)
}
Back
|
FazBrowse Home
|
New Git URL