# Path: wildfind/common/constants.py
# LOG_SIZE = 50


import sqlite3
from wildfind.common.constants import LOG_SIZE
           '    Level real,'
           '    Lon real,'
           '    Lat real,'
           '    foreign key (TimeStamp) REFERENCES Scans (TimeStamp)'
           '        on delete cascade)')
    cursor.execute(cmd)


def __create_table_log(cursor):
    cmd = ('create table if not exists '
           'Log ('
           '    Id integer primary key autoincrement,'
           '    TimeStamp integer,'
           '    Message )')
    cursor.execute(cmd)


def __create_tables(cursor):
    __create_table_info(cursor)
    __create_table_scans(cursor)
    __create_table_signals(cursor)
    __create_table_log(cursor)

    # Log pruning trigger
    cmd = ('create trigger if not exists LogPrune insert on Log when '
           '(select count(*) from log) > {} '
           'begin'
           '    delete from Log where Log.Id not in '
           '      (select Log.Id from Log order by'
           '          Id desc limit {});'

# Path: wildfind/common/constants.py
# LOG_SIZE = 50


# Path: wildfind/common/database.py
import sqlite3
from wildfind.common.constants import LOG_SIZE

           '    Level real,'
           '    Lon real,'
           '    Lat real,'
           '    foreign key (TimeStamp) REFERENCES Scans (TimeStamp)'
           '        on delete cascade)')
    cursor.execute(cmd)


def __create_table_log(cursor):
    cmd = ('create table if not exists '
           'Log ('
           '    Id integer primary key autoincrement,'
           '    TimeStamp integer,'
           '    Message )')
    cursor.execute(cmd)


def __create_tables(cursor):
    __create_table_info(cursor)
    __create_table_scans(cursor)
    __create_table_signals(cursor)
    __create_table_log(cursor)

    # Log pruning trigger
    cmd = ('create trigger if not exists LogPrune insert on Log when '
           '(select count(*) from log) > {} '
           'begin'
           '    delete from Log where Log.Id not in '
           '      (select Log.Id from Log order by'
           '          Id desc limit {});'

           'end;').format(LOG_SIZE, LOG_SIZE - 1)