0

I am trying to build an sqlite db, and having timestamp as one of the columns.

This is my structure:

CREATE TABLE logs (
log_id INTEGER PRIMARY KEY AUTOINCREMENT,
log_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
error_text TEXT
)

but when I am inserting into the table the log_date field remain blank:
INSERT INTO logs(error_text)VALUES("some error text")

What am I doing wrong?

user2979757
  • 783
  • 2
  • 8
  • 12

2 Answers2

0

Don't use null as placeholder in your insert query

This works

INSERT INTO logs(error_text)
VALUES("some error text");

This not

INSERT INTO logs(error_text, log_date)
VALUES("some error text", null);

SQLFiddle demo

juergen d
  • 201,996
  • 37
  • 293
  • 362
0

I just had potentially the same issue, and found your question while looking for a solution.

In my case the issue is that SQLite Administrator is showing '0' in all the log_date columns. However writing a "SELECT * from logs" in my C# application shows that the data is correct, even from previous sessions, before I'd noticed the issue (Changed names to match your schema).

So I'm putting this down to a bug in SQLite Administrator, although did not find confirmation with a quick Google search.

Andy Yelland
  • 61
  • 1
  • 4