4

The goal is to make a database out of a .sql file.

I'm trying to set up a local environment to test and modify this red5 implementation

Step 1 is

Create a database using the SQL command in database/database.sql

I'm on Windows, so I'm on Cygwin, with sqlite3 and a few other things installed, so I figured I'd make a database out of that.

When I try to load the file (That I moved) in an effort to make a database out of it, I get this.

$ sqlite3
SQLite version 3.7.16.2 2013-04-12 11:52:43
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .load database.sql
Error: %1 is not a valid Win32 application.

I've googled around and this seems to be a problem with the file path to the application.

The actual path is D:\cygwin\home\Houseman\database.sql

I'm in my home directory when I run sqlite3, so it should be right there, and accessible.

How can I do this?

Also, if there's a better way about setting up a temporary database so that I can test this application that is, apparently, dependent upon databases, that'd be helpful too.

Thanks


My database.sql file is

   CREATE TABLE `vpVideo` (
  `ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `userID` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `createDate` bigint(20) DEFAULT NULL,
  `vidExists` varchar(1) DEFAULT 'N',
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;

When I do .read database.sql I get

Error: near line 1: near "unsigned": syntax error


So I took out the unsigned and the ENGINE=myISAM stuff, as well as the AUTO_INCREMENT and now It seems to work.

At least it doesn't throw errors when I do .read

So I think it worked. Can I view a file somewhere to see the result?

8
  • 2
    did you try sqlite> .read <filename> Commented May 23, 2013 at 16:52
  • @matthiasLuag No I didn't... But now I did and I get a syntax error. I'll update my question Commented May 23, 2013 at 16:55
  • 1
    mh is the sql exported from a sqlite database? Sqlite (as do other vendors of sql databases) extended the standard SQL-92 (en.wikipedia.org/wiki/SQL-92) syntax so that exports may not be cross compatible between different vendors of databases Commented May 23, 2013 at 16:57
  • 1
    ok since your have MyISAM in your export, it seems to be from MySQL. Remove the entire stuff ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8 and remove the unsigned Commented May 23, 2013 at 16:59
  • 1
    Probably sqlite3 just doesn't support some of the syntax in your file (as others have said in more detail). Commented May 23, 2013 at 17:03

1 Answer 1

2

Your exports is taken from a MySQL database hence the MyISAM. This will work for you

CREATE TABLE vpVideo (
  ID int(11) NOT NULL,
  userID int(11) DEFAULT NULL,
  name varchar(255) DEFAULT NULL,
  createDate bigint(20) DEFAULT NULL,
  vidExists varchar(1) DEFAULT 'N',
  PRIMARY KEY (ID)
);

AUTOINCREMENT is done automatically with the definition of your primary key

Imports between different databases only work if it is done with the SQL-92 standard. All vendors of databases extended that standard, so that SQL-92 is only a subset of the entire sqlite syntax (as it is for others like oracle, db2, mysql)

Sign up to request clarification or add additional context in comments.

4 Comments

Yeah, that worked. I'm assuming that MySQL syntax is a bit different than sqlite? So .read works. Did it create my database with .read?
exactly, I added the explantation for different sql syntax
Thanks. One more thing where might my database be stored, so I can link my project to it later?
hehe :) start sqlite with sqlite3 mydatabase.db and it will be right in your current path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.