This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/myddas/sqlite3/sqlitest.yap

92 lines
1.6 KiB
Plaintext
Raw Normal View History

2018-06-26 15:35:47 +01:00
:- stop_low_level_trace.
:- use_module(library(maplist)).
2018-06-22 23:55:50 +01:00
:- use_module(library(myddas)).
2017-11-18 00:04:42 +00:00
main :-
2018-03-19 15:41:06 +00:00
init,
main_,
close.
2017-11-18 00:04:42 +00:00
main_ :-
go,
fail.
main_ .
init :-
2018-06-22 23:55:50 +01:00
2018-06-26 15:35:47 +01:00
start_low_level_trace,
2018-03-19 15:41:06 +00:00
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
2018-06-22 23:55:50 +01:00
writeln('chinook has landed').
2018-06-18 12:16:36 +01:00
2018-06-22 23:55:50 +01:00
go :-
2018-06-26 15:35:47 +01:00
db_import('artists', artist),
writeln(('artist -> artist')),
db_import('albums', album),
writeln(('albums -> album')),
db_import('track', track),
writeln(('track -> track')).
2017-11-18 00:04:42 +00:00
go :-
db_get_attributes_types(album,Als),
2018-06-22 23:55:50 +01:00
format('~w -> ~w~n',[album,Als]),
2017-11-18 00:04:42 +00:00
db_get_attributes_types(track,Ts),
2018-06-26 15:35:47 +01:00
format('~w -> ~w~n',[track,Ts]),
2018-06-22 23:55:50 +01:00
db_get_attributes_types(artist,As),
format('~w -> ~w~n',[artist,As]).
2017-11-18 00:04:42 +00:00
go :-
db_number_of_fields(album,Als),
db_number_of_fields(track,Ts),
db_number_of_fields(artist,As),
writeln(As:Als:Ts).
2018-03-19 15:41:06 +00:00
go :-
2018-06-22 23:55:50 +01:00
db_describe(album, Desc), writeln(album:Desc).
go :-
db_describe(track, Desc), writeln(track:Desc).
go :-
db_describe(artist, Desc), writeln(artist:Desc).
2018-03-19 15:41:06 +00:00
go :-
2018-06-22 23:55:50 +01:00
db_show_tables(Desc), writeln(tables:Desc).
2018-03-19 15:41:06 +00:00
go :-
2017-11-18 00:04:42 +00:00
db_show_tables(table(T)),
db_describe(T,tableinfo(FieldID,Type,Null,Primary,Default,'')),
writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')).
2018-03-19 15:41:06 +00:00
go :-
2017-11-18 00:04:42 +00:00
go_cut0.
go :-
%stop_low_level_trace,
findall(X:Y,artist(X,Y),Ls),
length(Ls,Total),
sort(Ls, LLs),
length(LLs, T),
writeln(T:Total).
go :-
go_cut1.
go :-
X=1,
artist(X,Y),
writeln(X:Y).
go_cut0 :-
% start_low_level_trace,
artist(X,Y),
writeln(X:Y),
!.
go_cut1 :-
X=1,
artist(X,Y),
writeln(X:Y),
!.
close :-
db_close.
2018-03-19 15:41:06 +00:00
:- main.