Add a function to fetch information about a table

Mostly so whether a field can contain NULL values can be determined.
This commit is contained in:
Christopher Baines 2020-03-29 10:29:08 +01:00
parent b30904e1af
commit bddf7a4240

View file

@ -114,6 +114,21 @@
'() '()
lst)) lst))
(define (table-schema conn table-name)
(map
(match-lambda
((column_name data_type is_nullable)
(list column_name
data_type
(string=? is_nullable "YES"))))
(exec-query
conn
"
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = $1"
(list table-name))))
(define* (insert-missing-data-and-return-all-ids (define* (insert-missing-data-and-return-all-ids
conn conn
table-name table-name