Skip to content

CIS1250Python/MlengelaPD11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The program - GEO POINTS DATABASE - changes the MlengelaPD8 so that instead of reading in a list of five or more points from a file, the project will read the points in from a database. Here's what the program does:

  1. The created program creates a database and inserts at least five points. The following are the points to be used:
    • 35.0714,106.6289, Main Campus
    • 35.0998,104.0639, Montoya
    • 35.2328,106.6630, Rio Rancho
    • 35.0856,106.6493, STEMULUS Center
    • 35.1836,106.5939, ATC
  2. Run the database to initialize the code to create the database.
  3. Modify the GUI program from MlengelaPD10 so that it reads points from my database instead of a file.

Basic Process:

The Program manipulates the database with the following applications:

  1. SQLite3 Library, which is included with my Python installation. A programmer can also pipping install it whenever necessary.
    • import sqlite3
  2. There must be a connection to a database to be able to write to it.
    • conn=sqlite3.connect('Mlengeladabase.db')
  3. If 'Mlengeladabase.db' does not exist, then it will create it.
  4. 'Mlengeladabase.db' will then appear in the same directory as the program (Unless you provide a path, then it will appear there instead)
  5. A cursor must be used to execute SQL queries
    • curs=conn.cursor()
  6. Once all changes are done, you must commit them to the database
    • conn.commit()
    • You can and should commit each time you've modified the database, not just when you're ready to close it.
  7. When you no longer need access to the database, use the close method to close it.
    • conn.close()
    • This is important when multiple users are using the database, since most databases can only support a limited number of simultaneous connections.

Structured Query Language (SQL)

  • Language designed to provide commands to databases.
  • Provides capabilities to:
    • Create rows of data in tables
    • Read data from tables
    • Update data in tables
    • Delete data from tables
  • CRUD is a common acronym to refer to data functions
  • SQL also provides you the capability to Create and Delete tables from databases.
  • In SQLite, table rows normally have a 64-bit signed integer ROWID, which is unique among all rows in the same table.
  • WITHOUT ROWID addition to tables is the exception.
  • Execute SQL statements on a database
  • Pass a SQL command to the cursor.execute method as a string:
    • curs.execute('..SQL command...')

Create a table

image

The program appears like this:

image

SQL CREATE TABLE

image

SQL INSERT INTO

image

##SQL UPDATE image

##SQL DELETE image

Delete the existing database, then add some code to insert some starting data

image

Initialize a Set of Data

image

Create a program that performs Create, Read, Update, and Delete functions on the database.

fetchall()

image

As the program runs:

image

Display one record

image

As it runs:

image

##Formatting Output image

image

Insert Data

image image

Update Data

image

Delete Data

image

Summary

  • Sqlite3
  • Connections
  • Commit
  • Close
  • Basic Process
  • SQL
  • Initializing a Database
  • CRUD

About

Geo-Points Database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published