Sqlite cyclically inserts data in batches using batch files

Source: Internet
Author: User

A large amount of test data needs to be inserted into the sqlite database and the transaction is intended to be inserted cyclically. However, sqlite does not support the definition of the declare variable, so it cannot be achieved by defining the cyclic variable value.

You need to use a batch processing file to repeatedly call the insert sqlite statement. The method is as follows:
Create a batch file named sqlite. bat that is called cyclically.Copy codeThe Code is as follows: @ ECHO OFF
For/L % I in (10000,) do (sqlite3.exe test. db <insertdb. bat)
Pause

This file indicates that loop 10000 calls insertdb. bat to operate the test. db database. Write the sqlite statement in the insertdb. bat file.Copy codeThe Code is 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; otherwise, sqlite execution may fail. Sqlite. bat, insertdb. bat, and test. db files must be stored 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.