Python access to the database

Source: Internet
Author: User

The PYTHON DB API (SPEC) framework can be written at once while accessing Mysql\ Oracle \sqlserver ... Different database servers, the confusion of the Unified interface program.

1. Connection access: Connection (motorway)

Create method: MYSQLDB.C conflict (parameter: Host address port port number user passwd DB name CharSet connection encoding)

Connection object Support methods:

Cursor used to create a return

Commit Commit

Rollback rollback

Close closes

2. Data interaction: Cursor (van)//3. Exception class: Exception (Accident) Try ... Exceptcursor object supported methods:

Execute executes database queries and commands; client <==> server

Fetchone get the next line of the result set

Fetchmany ... Next few lines;

Fetcall gets the remainder of the result set, so the line

RowCount last execute returns the number of rows of data or affects the number of rows

Close Cursor Object

3. Close Cursor Connectione

=======================================

Additions and deletions: Inser Update Delete operation database

Python access to the database

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.