Skip to main content

Posts

Showing posts with the label sql

Reality Is An Illusion

Reality is an illusion. The universe is a hologram. Buy gold. Bye! - Bill Cipher, Gravity Falls Ah what an interesting thought process Bill has. Sure he was evil as all get out, I mean who wouldn’t be after all he is a triangle. No, not the triangle from the song, however he might be? I’m not sure where the shoe runners got the inspiration for Bill Cipher to be honest. He’s pure evil, that’s for sure. But it does bring about a question. What if this life is an illusion? We can’t say for sure it’s not. We live day in and day out wondering if life will be what it is meant to be, or how it’s meant to be processed. Maybe this life isn’t more than it’s cracked up to be. It could be whatever it wants to be and we are left here picking up the pieces wondering if there’s something more to behold from it all. I’m not sure. It would be nice to be able to figure out what this life has in store for us. I mean, come on. There has to be something this life is good at, right? I sure as hell ho...

SQLite Read File

There is a simple way to read a file into a SQLite database. The syntax looks like this: INSERT INTO images(name, img) VALUES('my_photo', readfile('photo.jpg')); Naturally you wouldn’t want to do this for very large files. The database would grow rather large I would expect and might become unmanagable. But for small files like icons? Things like that? Yeah I don’t see why not. Seems like such a simple little thing to do doesn’t it. Yeah, that’s what I was thinking.

Files Table in sql for SQLite3

Here's some code I'm working on for a sqlite3 database to store backup file content. Might add a BLOB type later for storing binary data. Not sure yet. PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE files (id INTEGER PRIMARY KEY, name TEXT, content TEXT, created_ts TEXT, modified_ts TEXT); CREATE TABLE files_log(id INTEGER PRIMARY KEY, fileid TEXT, name TEXT, content TEXT, created_ts TEXT, modified_ts TEXT, dt TEXT); CREATE TRIGGER files_trig AFTER INSERT ON files BEGIN update files SET created_ts = datetime('now','localtime') WHERE id = NEW.id; END; CREATE TRIGGER files_update_trig AFTER UPDATE ON files BEGIN update files SET modified_ts = datetime('now','localtime') WHERE id = OLD.id; insert into files_log(fileid, name, content, created_ts, modified_ts) values(OLD.id, OLD.name, OLD.content, OLD.created_ts, OLD.modified_ts); END; CREATE TRIGGER files_log_update_trig AFTER INSERT ON files_log BEGIN update fi...