SQLite cyclic BULK Insert data with batch file implementation _sqlite

Source: Internet
Author: User
Tags bulk insert sqlite sqlite database
A large number of test data needs to be inserted into the SQLite database, and the intention is to loop the insert operation with a transaction, although SQLite does not support declare variable definitions and cannot be implemented by defining the loop variable value.

You need to iterate through a batch file to insert the SQLite statement in the following way
Create a circular call to the batch file Sqlite.bat, the contents of the file
Copy Code code as follows:

@ECHO off
FOR/L%%i in (1,1,10000) do (Sqlite3.exe Test.db<insertdb.bat)
Pause

This file indicates that the loop 10000 call Insertdb.bat operates on the TEST.DB database. Write the SQLite statement in the Insertdb.bat file.
Copy Code code as follows:

INSERT into Test (COL1,COL2,COL3,COL4,COL5,COL6,COL7,)
Values
(' col1 ', ' col2 ', ' col3 ', ' col4 ', ' col5 ', 6,7);

NOTE: The SQL statement in the Insertdb.bat file must end with a semicolon, or it will cause an error in the execution of SQLite. sqlite.bat,insertdb.bat,test.db files need to be placed in the same directory
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.