Giter Site home page Giter Site logo

hodel33 / sqlite-x33 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

Crafted in just 33 lines, this SQLite Context Manager allows you to effortlessly manage and query SQLite databases with sql.execute(db, query). Designed for integration and simplicity, it pairs perfectly with @yy0931's SQLite3 Editor for VSCode. Cheers to seamless SQL editing! πŸš€ - @hodel33 & @dyaland

Python 100.00%

sqlite-x33's Introduction

SQLiteX33

πŸ“‹ Overview

SQLiteX33 is a lightweight and streamlined context manager for SQLite databases in Python.
It simplifies the process of running SQL queries and ensures best practices such as committing transactions and closing connections.

🌟 Features

  • Seamless SQLite Connection Management: Easily manage SQLite database connections without the hassle.
  • External Execute Function: Provides a handy external function to execute SQL commands, making it easier to integrate into other modules.
  • Foreign Key Support: Automatically enables FOREIGN KEYS for SQLite 3 out of the box.

βš™οΈ Installation

πŸ› οΈ Prerequisites

  1. 🐍 Python: SQLiteX33 is a Python context manager. Ensure you have Python installed on your system. You can download it from Python's official website.

  2. πŸ–‹οΈ IDE: For code editing, VS Code (Visual Studio Code) is recommended. Enhance your Python experience by adding the Python extension.

  3. πŸ” SQLite Extension (Optional): For easier overview and editing of SQLite databases, it's good to have an SQLite extension. @yy0931's SQLite3 Editor for VSCode is highly recommended.

⬇️ Steps

To set up SQLiteX33 in your project:

  1. Download: Download the sqlite_x33.py file from this repository.

  2. Place in Project Directory: Move the sqlite_x33.py file to the root directory of your Python project, or where you plan on using SQLiteX33.

  3. Import and Use: Follow the usage instructions below to get started with SQLiteX33.


πŸš€ Usage

1. Import the Python Module

To use SQLiteX33, first import the module in your Python script:

import sqlite_x33 as sql

2. Using the Context Manager

Fetching Data

result = sql.execute("path_to_db.db", "SELECT * FROM table_name")

Inserting Data

sql.execute("path_to_db.db", "INSERT INTO table_name (column1, column2) VALUES ('value1', 'value2')")

Updating Data

sql.execute("path_to_db.db", "UPDATE table_name SET column1 = 'new_value' WHERE column2 = 'value2'")

Deleting Data

sql.execute("path_to_db.db", "DELETE FROM table_name WHERE column1 = 'value1'")

⚠️ Important Notes

  • The sql.execute() function returns the result of a SELECT query. If the SQL command was an INSERT/UPDATE/DELETE, it returns None.
  • This context manager allows only one SQL query to be executed at a time. To run multiple queries, call sql.execute() separately for each query.
  • Ensure the SQLite database file path provided is correct.

πŸ’‘ Credits

Developed by hodel33 & dyaland. Enjoy and have fun! πŸ’«


πŸ’¬ Feedback & Contact

I'd love to network, discuss tech, or swap music recommendations. Feel free to connect with me on:

🌐 LinkedIn: Bjârn Hâdel
🐦 Twitter: @hodel33
πŸ“Έ Instagram: @hodel33
πŸ“§ Email: [email protected]

sqlite-x33's People

Contributors

hodel33 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.