Python database SQLite

Source: Internet
Author: User

SQLite:

The main features of lightweight database SQLite: 1. support events, no configuration, no installation, no administrator; 2. Support for most sql92;

 

3. A complete database is saved as a file on the disk. The same database file can be used on different machines. The maximum size of the database is 2 TB,

 

The support for characters and blob is only limited to available memory; 4. The entire system is less than 30 thousand lines of code, less than KB of memory (GCC ),

 

Most applications are faster than common Client/Server databases, with no other dependencies. 5. Open source code. Code 95% has good comments and easy-to-use APIs.

 

The official version is compiled with TCL.

 

 

 

SQLite is rapidly becoming popular and can be used on various platforms. python2.5 integrates the pysqlite database interface program described earlier,

 

As a version later than python2.5, The sqlite3 module is integrated. This is the first time that the python standard library has incorporated a database interface program into the standard library,

 

Maybe this marks a new beginning.

 

 

Next we will show you the most basic operations on the SQLite database in Python.

 

Import sqlite3 <br/> CNX = sqlite3.connect ('d:/database/SQLite. db') <br/> cur = CNX. cursor () <br/> cur.exe cute ('drop table users') <br/> cur.exe cute ('create table users (LOGIN varchar (8), uid integer )') <br/> cur.exe cute ('insert into users values ("John", 100) ') <br/> cur.exe cute ('insert into users values ("Jake", 1120) ') <br/> cur.exe cute ('insert into users values ("Wang", 1120)') <br/> cur.exe cute ('select * From users ') <br/> for eachuser in cur. fetchall (): <br/> Print eachuser 

 

First, reference the sqlite3 module and use connect to create a data connection. Create a cursor through a connection, and then execute common SQL commands through the cursor

 

Running result:

 

 

Here only show the most basic Connection database, and execute SQL, more operations can see the official website http://www.sqlite.org/

 

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.