remove cron tasks
This commit is contained in:
parent
185641e6d0
commit
5f28274706
10 changed files with 50 additions and 148 deletions
|
|
@ -6,9 +6,6 @@ import sqlite3
|
|||
connection = sqlite3.connect("db.sqlite")
|
||||
cursor = connection.cursor()
|
||||
|
||||
# What script performs:
|
||||
# - first, remove site table: crash here if table doesn't exist (compatibility test without effort)
|
||||
# - remove site_id colum from comment table
|
||||
script = """
|
||||
CREATE TABLE comment (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
import sqlite3
|
||||
import datetime
|
||||
from ulid import ULID
|
||||
|
||||
# add column ulid
|
||||
connection = sqlite3.connect("db.sqlite")
|
||||
cursor = connection.cursor()
|
||||
script = """
|
||||
PRAGMA foreign_keys = OFF;
|
||||
BEGIN TRANSACTION;
|
||||
ALTER TABLE comment ADD ulid INTEGER;
|
||||
COMMIT;
|
||||
PRAGMA foreign_keys = ON;
|
||||
"""
|
||||
cursor.executescript(script)
|
||||
connection.close()
|
||||
|
||||
# fill in ulid column
|
||||
connection = sqlite3.connect("db.sqlite")
|
||||
cursor = connection.cursor()
|
||||
updates = []
|
||||
for row in cursor.execute('SELECT * FROM comment'):
|
||||
row_id = row[0]
|
||||
string_created = row[2]
|
||||
date_created = datetime.datetime.strptime(string_created, "%Y-%m-%d %H:%M:%S")
|
||||
ulid = ULID.from_datetime(date_created)
|
||||
update = "UPDATE comment SET ulid = " + str(int(ulid)) + " WHERE id = " + str(row_id)
|
||||
print(update)
|
||||
updates.append(update)
|
||||
|
||||
for update in updates:
|
||||
pass
|
||||
connection.execute(update)
|
||||
connection.commit()
|
||||
connection.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue