31 lines
977 B
Python
31 lines
977 B
Python
import sqlite3
|
|
import os
|
|
import argparse
|
|
import json
|
|
import getpass
|
|
import datetime
|
|
import logging
|
|
import action
|
|
|
|
def create_action(cursor, project_id = '', task_id = '', note_id = '', message = ''):
|
|
query = """
|
|
INSERT INTO action (project_id, task_id, note_id, username, message, created_at)
|
|
VALUES (?, ?, ?, ?, ?, ?);
|
|
"""
|
|
|
|
cursor.execute(query, (project_id, task_id, note_id, getpass.getuser(), message, datetime.datetime.now(),))
|
|
|
|
logging.debug('created action')
|
|
|
|
def read_last_action(conn):
|
|
logging.info('> last_action')
|
|
# query = 'SELECT * FROM action WHERE id = (SELECT MAX(id) FROM action'
|
|
# query = 'SELECT project_id, task_id, note_id FROM action'
|
|
query = 'SELECT project_id, task_id, note_id FROM action ORDER BY created_at DESC LIMIT 1;'
|
|
|
|
cursor = conn.cursor()
|
|
cursor.execute(query)
|
|
logging.debug('DEEEEEEEEBU')
|
|
last_action = cursor.fetchone()
|
|
logging.debug(last_action)
|
|
return last_action |