Search code examples
sqlitecygwinred5

Create sqlite3 database from .sql file


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?


Solution

  • 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)