sql_lib.html


001| '''SQL Library.
001| 
001| Each entry (tuple) in the library has the format:
001| 
001|     [0] - the SQL text
001|     [1] - format string for results (empty string allowed)
001|     [2] - headers tuple (each member is one line to print - empty tuple means no lines)
001| 
001| '''

002| ####################################################################################################
003| ####################################################################################################
004| 
005| ##------------------------------------------------------------------------------------------------##
006| # SQL Library...
007| SqlLib = {
008| 
009| '_': (
010| '''
010| SELECT F.name, P.path
010| FROM "filelinks" AS "L"
010|   LEFT JOIN "filenames" AS "F" ON (L.fid=F.fid)
010|   LEFT JOIN "filepaths" AS "P" ON (L.pid=P.pid)
010| WHERE (F.fid IN (SELECT F.fid
010|   FROM "filelinks" AS "L" JOIN "filenames" as "F" ON (L.fid=F.fid)
010|   GROUP BY F.hash HAVING (10 < count(*))))
010| ORDER BY F.name, F.fid, P.path
010| '''
,
011| '',
012| ()
013| ),
014| 
015| '@': (
016| '''
016| SELECT *
016| FROM "%s"
016| ORDER BY 1
016| '''
,
017| '',
018| ()
019| ),
020| 
021| 'path.dups': (
022| '''
022| SELECT "name", count(*) AS "N"
022| FROM "filepaths"
022| GROUP BY "name"
022| HAVING (1 < "N")
022| ORDER BY "name"
022| '''
,
023| '%s (%d)',
024| ('Pathname #dups')
025| ),
026| 
027| 'file.dups': (
028| '''
028| SELECT count(*) AS "N", F.name, min(P.path)
028| FROM "filelinks" AS "L"
028|   JOIN "filenames" AS "F" ON (L.fid=F.fid)
028|   JOIN "filepaths" AS "P" ON (L.pid=P.pid)
028| GROUP BY F.hash, F.name
028| HAVING (1 < "N")
028| ORDER BY "N" DESC, F.name
028| '''
,
029| '%d: %s [%s]',
030| ('Filename #dups')
031| ),
032| 
033| 'path.list': (
034| '''
034| SELECT "name", "path"
034| FROM "filepaths"
034| ORDER BY "name", "path"
034| '''
,
035| '%-32s [%s]',
036| ('Directory Name [Full Path]',
037|  '-------------------------------- ------------------------------------------------------------'
038|  )
039| ),
040| 
041| 'file.list': (
042| '''
042| SELECT "name","size","dcr","dlm","hash"
042| FROM "filenames"
042| ORDER BY "name","dcr" DESC
042| '''
,
043| '%-32s %6d %10.2f %10.2f [%s]',
044| ('File Name FSize Created Updated [File Hash] ',
045|  '-------------------------------- ------ ---------- ---------- ----------------------------------------------------------------------------------------------------------------------------------'
046|  )
047| ),
048| 
049| # ...end of LIB
050| }
051| 
052| ####################################################################################################
053| '''eof'''
054|