Peter Jay Salzman wrote:
> Hi all,
> 
> I know very little about mysql and sqlite - I've only played
> around a little bit with databases, so I'm a newbie in this area.
> 
> There's a blogger called Wheatblog that I've been trying to
> convert from mysql to sqlite so I don't have to run a full
> RDMBS deamon on my underpowered machine for just a single
> blog program.
> 
> I think I've successfully replaced all the mysql calls with
> wrapper functions that use sqlite functions.  There's just a
> few bits left that are causing errors, and I'm having trouble fixing
> them. 
> 
> Here's the bit of mysql sql that creates the database used by
> Wheatblog.  It came in the Wheatblog zip file.  I'm surprised
> to see the accent grave (`):
> 
> 
>    CREATE TABLE `wheatblog_categories` (
>      `id` int(11) NOT NULL auto_increment,
>      `category` varchar(30) NOT NULL default '',
>      PRIMARY KEY  (`id`)
>    ) TYPE=MyISAM;
> 
>    CREATE TABLE `wheatblog_comments` (
>      `id` int(11) NOT NULL auto_increment,
>      `comment_author_name` varchar(100) NOT NULL default '',
>      `comment_author_email` varchar(100) NOT NULL default '',
>      `comment_author_url` varchar(100) NOT NULL default '',
>      `comment_body` mediumtext NOT NULL,
>      `post_id` int(11) NOT NULL default '0',
>      `comment_month` int(2) NOT NULL default '0',
>      `comment_date` int(2) NOT NULL default '0',
>      `comment_year` int(4) NOT NULL default '0',
>      PRIMARY KEY  (`id`)
>    ) TYPE=MyISAM;
> 
>    CREATE TABLE `wheatblog_posts` (
>      `id` int(11) NOT NULL auto_increment,
>      `day` varchar(10) default '',
>      `month` int(2) NOT NULL default '0',
>      `date` int(2) NOT NULL default '0',
>      `year` int(4) NOT NULL default '0',
>      `category` int(1) NOT NULL default '1',
>      `showpref` tinyint(1) default '1',
>      `body` mediumtext NOT NULL,
>      `title` varchar(100) default '',
>      `number_of_comments` int(11) NOT NULL default '0',      PRIMARY
>    KEY  (`id`) ) TYPE=MyISAM;
> 
>    INSERT INTO `wheatblog_categories` (id, category)
>      values (null, 'unfiled');
> 
> 
> And here's how I've tried to implement it on sqlite using
> PHP.  Note that
> DB_query() is a wrapper for sqlite_query().  I've changed the
> "auto_increment" to "INTEGER PRIMARY KEY", as the FAQ said.
> I'm very new to SQL, but I guess "INTEGER PRIMARY KEY" and
> "NOT NULL" aren't separated by commas?
> 
> 
>    function Create_Wheatblog_Database( $db )
>    {
>       $cmd =
>       "CREATE TABLE 'wheatblog_categories' (
>         'id' INTEGER PRIMARY KEY NOT NULL,
>         'category' varchar(30) NOT NULL default '',
>       ) TYPE=MyISAM;";                               <-------
> 
>       echo "<p>$cmd</p>";
>       DB_query($cmd, $db);
> 
> 
>       $cmd =
>       "CREATE TABLE 'wheatblog_comments' (
>         'id' INTEGER PRIMARY KEY NOT NULL,
>         'comment_author_name' varchar(100) NOT NULL default '',
>         'comment_author_email' varchar(100) NOT NULL default '',
>         'comment_author_url' varchar(100) NOT NULL default '',
>         'comment_body' mediumtext NOT NULL,
>         'post_id' int(11) NOT NULL default '0',
>         'comment_month' int(2) NOT NULL default '0',
>         'comment_date' int(2) NOT NULL default '0',
>         'comment_year' int(4) NOT NULL default '0',       )
> TYPE=MyISAM;"; 
> 
>       DB_query($cmd, $db);
> 
> 
>       $cmd =
>       "CREATE TABLE 'wheatblog_posts' (
>         'id' INTEGER PRIMARY KEY NOT NULL,
>         'day' varchar(10) default '',
>         'month' int(2) NOT NULL default '0',
>         'date' int(2) NOT NULL default '0',
>         'year' int(4) NOT NULL default '0',
>         'category' int(1) NOT NULL default '1',
>         'showpref' tinyint(1) default '1',
>         'body' mediumtext NOT NULL,
>         'title' varchar(100) default '',
>         'number_of_comments' int(11) NOT NULL default '0',       )
> TYPE=MyISAM;"; 
> 
>       DB_query($cmd, $db);
> 
> 
>       $cmd =
>       "INSERT INTO 'wheatblog_categories' (id, category)
>         values (null, 'unfiled');";
> 
>       DB_query($cmd, $db);
> 
>    }
> 
> 
> It appears that the error is a "syntax error" near where my arrow
> (<------) is.  Can someone throw some charity my way?   Is there
> anything obviously
> wrong here?
> 
> Thanks,
> Pete

you might want to make changes along the lines of:

CREATE TABLE `wheatblog_categories` (
     `id` int(11) NOT NULL auto_increment,
     `category` varchar(30) NOT NULL default '',
     PRIMARY KEY  (`id`)
   )

to 

CREATE TABLE wheatblog_categories (
     id int(11) NOT NULL auto_increment,
     category varchar(30) NOT NULL default '',
     PRIMARY KEY  (id)
   )

reid

Reply via email to