2018-06-30 00:57:41 +01:00
|
|
|
|
2018-11-06 22:53:47 +00:00
|
|
|
|
2018-11-25 13:27:48 +00:00
|
|
|
:- use_module(library(lists)).
|
|
|
|
:- use_module(library(maplist)).
|
2019-04-07 00:25:10 +01:00
|
|
|
:- use_module(myddas_core).
|
2018-11-25 13:27:48 +00:00
|
|
|
|
2019-04-05 16:56:01 +01:00
|
|
|
main :-
|
|
|
|
init,
|
|
|
|
main_,
|
|
|
|
close.
|
|
|
|
main_ :-
|
|
|
|
catch(go,E,writeln(E)),
|
|
|
|
fail.
|
|
|
|
main_ .
|
|
|
|
|
|
|
|
init :-
|
2019-04-07 00:25:10 +01:00
|
|
|
catch(db_open(sqlite3,con,('chinook.db'),_,_), _, fail),
|
2019-04-05 16:56:01 +01:00
|
|
|
% db_open(sqlite3, 'chinook.db', _, _),
|
|
|
|
writeln('chinook has landed').
|
|
|
|
|
|
|
|
go :-
|
|
|
|
writeln(('db_import')),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_import(con,'artists', artists),
|
2019-04-05 16:56:01 +01:00
|
|
|
writeln(('artist -> artists')),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_import(con,'albums', albums),
|
2019-04-05 16:56:01 +01:00
|
|
|
writeln(('albums -> albums')),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_import(con,'tracks', tracks),
|
2019-04-05 16:56:01 +01:00
|
|
|
writeln(('tracks -> tracks')).
|
|
|
|
|
|
|
|
|
|
|
|
go :-
|
|
|
|
% X=1,
|
|
|
|
artists(X,Y),
|
|
|
|
writeln(X:Y).
|
|
|
|
go :-
|
|
|
|
writeln(db_get_attributes_types),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_get_attributes_types(con,albums,Als),
|
2019-04-05 16:56:01 +01:00
|
|
|
format('~w -> ~w~n',[albums,Als]),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_get_attributes_types(con,tracks,Ts),
|
2019-04-05 16:56:01 +01:00
|
|
|
format('~w -> ~w~n',[tracks,Ts]),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_get_attributes_types(con,artists,As),
|
2019-04-05 16:56:01 +01:00
|
|
|
format('~w -> ~w~n',[artists,As]).
|
|
|
|
go :-
|
|
|
|
writeln(db_number_of_fields),
|
2019-04-07 00:25:10 +01:00
|
|
|
db_number_of_fields(con,albums,Als),
|
|
|
|
db_number_of_fields(con,tracks,Ts),
|
|
|
|
db_number_of_fields(con,artists,As),
|
2019-04-05 16:56:01 +01:00
|
|
|
writeln(As:Als:Ts).
|
|
|
|
|
|
|
|
go :-
|
|
|
|
|
2019-04-07 00:25:10 +01:00
|
|
|
db_describe(con,albums, Desc), writeln(albums:Desc).
|
2019-04-05 16:56:01 +01:00
|
|
|
go :-
|
2019-04-07 00:25:10 +01:00
|
|
|
db_describe(con,tracks, Desc), writeln(tracks:Desc).
|
2019-04-05 16:56:01 +01:00
|
|
|
go :-
|
2019-04-07 00:25:10 +01:00
|
|
|
db_describe(con,artists, Desc), writeln(artists:Desc).
|
2019-04-05 16:56:01 +01:00
|
|
|
go :-
|
2019-04-07 00:25:10 +01:00
|
|
|
db_show_tables(con,Desc), writeln(tables:Desc).
|
2019-04-05 16:56:01 +01:00
|
|
|
go :-
|
2019-04-07 00:25:10 +01:00
|
|
|
db_show_tables(con,table(T)),
|
|
|
|
db_describe(con,T,tableinfo(FieldID,Type,Null,Primary,Default,'')),
|
2019-04-05 16:56:01 +01:00
|
|
|
writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')).
|
|
|
|
|
|
|
|
|
|
|
|
go :-
|
|
|
|
writeln(access),
|
|
|
|
go_cut0.
|
|
|
|
|
|
|
|
|
|
|
|
go :-
|
|
|
|
%stop_low_level_trace,
|
|
|
|
findall(X:Y,artists(X,Y),Ls),
|
|
|
|
length(Ls,Total),
|
|
|
|
sort(Ls, LLs),
|
|
|
|
length(LLs, T),
|
|
|
|
writeln(T:Total).
|
|
|
|
|
|
|
|
go :-
|
|
|
|
go_cut1.
|
|
|
|
|
|
|
|
go_cut0 :-
|
|
|
|
artists(X,Y),
|
|
|
|
writeln(X:Y),
|
2018-11-17 23:39:55 +00:00
|
|
|
!.
|
2018-11-06 22:53:47 +00:00
|
|
|
|
2018-11-17 23:39:55 +00:00
|
|
|
|
2019-04-05 16:56:01 +01:00
|
|
|
go_cut1 :-
|
|
|
|
% X=1,
|
|
|
|
artists(X,Y),
|
|
|
|
writeln(X:Y),
|
2018-11-25 13:27:48 +00:00
|
|
|
!.
|
2018-11-06 22:53:47 +00:00
|
|
|
|
2019-04-05 16:56:01 +01:00
|
|
|
close :-
|
2019-04-07 00:25:10 +01:00
|
|
|
db_close(con).
|
2018-06-30 16:31:40 +01:00
|
|
|
|
2018-11-17 23:39:55 +00:00
|
|
|
|
2019-04-07 00:25:10 +01:00
|
|
|
:- initialization(main, now).
|