Giter Club home page Giter Club logo

datafun-05-sql's Introduction

datafun-05-sql

Project 5 integrates Python and SQL, focusing on database interactions using SQLite.

Created by: Nolan Moss

Project setup

  1. Create virtual environment
  • py -m venv .venv
  1. Activate environment
  • .\.venv\Scripts\Activate
  1. Install requirements
  • py -m pip install pandas pyarrow pathlib logging

alt text

  1. Freeze requirements
  • py -m pip freeze > requirements.txt

Functionality

The script performs the following operations:

  • Create Database: Creates an SQLite database file named project.db in the root project directory if it doesn't exist.
  • Create Tables: Executes SQL statements to create tables based on the schema defined.
  • Insert Data from CSV: Reads data from CSV files (data/authors.csv and data/books.csv) and inserts the records into their respective tables in the database.
  • Execute SQL from File: Executes SQL commands stored in separate SQL files located in the sql/ directory.
  • Main Function: Executes the main functionality of the script, including creating the database, tables, inserting data, and executing SQL commands.

SQL Operations

alt text

The script performs the following SQL operations:

  • Create Tables: Defines the structure of tables in the database.
  • Insert Records: Inserts data into tables from CSV files.
  • Update Records: Modifies existing records in the tables.
  • Delete Records: Removes records from the tables.
  • Query Aggregation: Performs aggregate functions (e.g., SUM, AVG) on the data.
  • Query Filtering: Retrieves specific records based on specified conditions.
  • Query Sorting: Orders the retrieved records based on specified criteria.
  • Query Grouping: Groups records based on specified attributes.
  • Query Joining: Combines data from multiple tables based on specified relationships.

datafun-05-sql's People

Contributors

crusoe22 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.