Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in my SQLite syntax

Tags:

sql

sqlite

New to SQLite so I don't know what I'm doing wrong. I'm just getting an error saying:

SQLSTATE[HY000]: General error: 1 near "CREATE": syntax error

Here's my SQL:

CREATE TABLE users (
  id INTEGER NOT NULL PRIMARY KEY,
  date_created DATETIME NOT NULL,
  date_updated DATETIME NOT NULL,
  username VARCHAR(32) NOT NULL,
  password VARCHAR(32) NOT NULL,
  role VARCHAR(32) NOT NULL DEFAULT 'member',
  first_name VARCHAR(50) NOT NULL,
  last_name VARCHAR(50) NOT NULL,
  email VARCHAR(128) NOT NULL
)

CREATE TABLE subscribers (
  id INTEGER NOT NULL PRIMARY KEY,
  name VARCHAR(40) DEFAULT NULL,
  email VARCHAR(255) NOT NULL UNIQUE
)

CREATE TABLE weekly_download (
  id INTEGER NOT NULL PRIMARY KEY,
  filename TEXT NOT NULL,
  download_date DATE NOT NULL,
  body TEXT
)
like image 299
Andrew Avatar asked Oct 22 '09 19:10

Andrew


People also ask

What is a Sqlite_schema error?

SQLite_Schema is an error code that is returned when there is a change in the database. The SQLite _schema error code is indicated when a prepared SQL statement is no longer valid and cannot be executed. These types of errors occur when using sqlite3 prepare () and sqlite3 step () interfaces to run SQL.

When can you get an SQLite schema error?

The SQLITE_SCHEMA error is returned when a prepared SQL statement is not valid and cannot be executed. Such type occurs only when using the sqlite3 prepare() and sqlite3 step() interfaces to run SQL.

Why SQLite database is locked?

OperationalError: database is locked errors indicate that your application is experiencing more concurrency than sqlite can handle in default configuration. This error means that one thread or process has an exclusive lock on the database connection and another thread timed out waiting for the lock the be released.


1 Answers

put a semicolon after each statement.

CREATE TABLE ( ... ) ;
CREATE TABLE ( ... ) ;
like image 181
marcc Avatar answered Nov 15 '22 07:11

marcc