How do I import .sql files into SQLite 3?
From a sqlite prompt:
sqlite> .read db.sql
Or:
cat db.sql | sqlite3 database.db
Also, your SQL is invalid - you need ;
on the end of your statements:
create table server(name varchar(50),ipaddress varchar(15),id init);
create table client(name varchar(50),ipaddress varchar(15),id init);
How to import a .sql file to sqlite via nodejs exec
Pipe |
is a shell tool for chaining commands. In Node you need to separate your commands and redirect first output to next input.
var fs = require("fs")
, spawn = require("child_process").spawn
, child = spawn("sqlite3", ["mydb.db"])
fs.createReadStream("./db.sql").pipe(child.stdin)
Related Topics
SQL Error: Ora-00933: SQL Command Not Properly Ended
Postgres SQL Insert Query Syntax Error from PHPpgadmin
Disable All Table Constraints in Oracle
How to Determine the Status of a Job
Changing the Commandtimeout in SQL Management Studio
How to Read the Contents of an .SQL File into an R Script to Run a Query
Update with Join Query in Oracle
Errors in SQL Server While Importing CSV File Despite Varchar(Max) Being Used for Each Column
Must Declare the Scalar Variable
Check If Current Date Is Between Two Dates Oracle SQL
Transform and Pivot in Access 2013 SQL
How to Separate String into Different Columns
Transposing an SQL Result So That One Column Goes Onto Multiple Columns