I am still very new to Sqlite3 programming and need some help with a new type of
ID: 3755899 • Letter: I
Question
I am still very new to Sqlite3 programming and need some help with a new type of problem. Here are the requirements. Any help or an example to study would be really helpful.
Using Vi or Vim (or compatible text editor), write a Sqlite3 program that will input the entire contents of a book (any electronic book) into a table with one sentence per line and a corresponding Id number for each line.Store the contents of the book in a file called book.txt and call the program build.sql.
This is really new to me so any help would be greatly appreciated.
Explanation / Answer
SQLite: SQLIte is lightweight SQL database which offers self-contained, serverless and transactional SQL database engine.The database file format is cross-platform that means one can freely copy a database between 32-bit and 64-bit systems. SQLite3 is more compact library with Manifest typing and Improved Concurrency.
Program:
# vi build.sql
/* creating database for storing a book data */
$ sqlite3 book.db
SQLite version 3.8.5
Enter ".help" for instructions
/* creating a table which is having two field ID and a Text */
sqlite> book.db CREATE TABLE t1 (ID INTEGER PRIMARY KEY AUTOINCREMENT , TextdataTEXT);"
/* Transfering a Book content to a TABLE */
BEGIN TRANSACTION;
/* Source database having BookContent */
ATTACH 'E:Program FilesDBSQLiteEbook.db' AS SourceDB;
/* Destination database is book.db which we created */
ATTACH 'D:DocumentsApplication_SQLiteVIDatabasebook.db' AS DestDB;
sqlite> INSERT INTO DestDB.Textdata SELECT * FROM SourceDB.Textdata;
COMMIT;
END TRANSACTION;
sqlite> select * from t1;
sqlite> .quit
$
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.