Python and SQLite

Databases are popular for many applications, especially for use with web applications or customer-oriented programs. Databases are good when discrete structures are to be operated on, such as a customer list that has phone numbers, addresses, past orders, and so on. A database can store a lump of data and allow the user or developer to pull the necessary information, without regard to how the data is stored. Additionally, databases can be used to retrieve data randomly, rather than sequentially. For pure sequential processing, a standard file is better.

A database (DB) is simply a collection of data, placed into an arbitrary structured format. The most common DB is a relational database; tables are used to store the data and relationships can be defined between different tables. Structured Query Language (SQL) is the language used to work with most DBs. (SQL can either be pronounced as discrete letters S-Q-L or as a word, sequel.)

SQL provides the commands to query a database and retrieve or manipulate information. The format of a query is one of the most powerful forces when working with DBs; an improper query won't return the desired information, or worse, it will return the wrong information. SQL is also used to input information into a DB.

While you can interact directly with a DB using SQL, as a programmer you have the liberty of using Python to control much of the interactions. You will still have to know SQL so you can populate and interact with the DB, but most of the calls to the DB will be with the Python database application programming interface (DB-API).

Starting with v2.5, Python has included SQLite, a lightweight SQL-based database management system. SQLite is written in C, so it's quick.

It also creates the database in a single file, which makes implementing a DB fairly simple; you don't have to worry about all the issues of having a DB spread across a server. However, it does mean that SQLite is better suited to either development purposes or small, standalone applications. If you are planning on using your Python program for large-scale systems, you'll want to move to a more robust database, such as PostgreSQL or MySQL.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.12.232