Skip to main content

This is a program designed to facilitate communication with the database, preventing unnecessary congestion in the source.

Project description

DBEase

DBEase is a Python module designed to simplify working with SQLite databases. It provides an easy-to-use interface for creating and managing tables based on a configuration file, without needing to write SQL commands.

Features

  • Automatically creates SQLite tables based on a database.ini configuration file.
  • Supports basic CRUD (Create, Read, Update, Delete) operations.
  • Infers column types from the configuration file.

Installation

No installation is required beyond ensuring you have Python and SQLite. Simply include the Database class in your project.

Configuration

The database.ini file defines the tables and columns for the database. If this file does not exist, it will be created with default content.

Example database.ini

[user]
first_name = Mohammad
last_name = Mohammadi
username = Aytola
password = TestPassword
age = 21
register = 08/12/2024,12:16:11

[admin]
first_name = Mohammad
last_name = Mohammadi
username = Aytola
password = TestPassword

Adding New Tables or Columns

To add new tables or columns:

Edit database.ini: Open the database.ini file and add your new tables or columns. Ensure the syntax is correct. Delete the Existing Database File: Delete the existing DataBase.db file if it exists. This is necessary because the database will be recreated based on the updated database.ini file. Re-run the Script: When you run the script again, the DataBase.db file will be recreated with the new tables and columns defined in database.ini.

Usage

Importing and Connecting

    from DBEase import database  # Replace `DBEase` with the actual module name

    # Create a Database instance and connect
    db = database()

Creating Tables

Tables will be created automatically based on the database.ini file when you connect to the database. If tables already exist, they will not be recreated

Performing CRUD Operations

Inserting Data

    table = db.nametable
    db.table = table.user
    db.data = {'first_name': 'Mehran', 'last_name': 'Mohammadi', 'username': 'YarNovin', 'password': 'Testpassword', 'age': 29, 'register': '08/12/2024,12:16:11'}
    row_id = db.insert
    print(f"Inserted row ID: {row_id}")

Querying Data

db.query = {'username': 'YarNovin'}
records = db.get
for record in records:
    print(record)

Checking for Records

exists = db.check
print(f"Records exist: {exists}")

Retrieving All Data

all_records = db.all
for record in all_records:
    print(record)

Updating Data

db.query = {'username': 'YarNovin'}
db.data = {'password': 'NewPassword'}
db.set

Deleting Data

db.query = {'username': 'YarNovin'}
db.delete

Notes

  • Ensure the database.ini file is correctly configured before running the script.
  • To apply changes to the database schema, modify the database.ini file and delete the existing DataBase.db file. Re-run the script to recreate the database with the updated schema.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbease-1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbease-1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file dbease-1.0.tar.gz.

File metadata

  • Download URL: dbease-1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for dbease-1.0.tar.gz
Algorithm Hash digest
SHA256 f030e7374d1e7fc9f6ee7fb786cb5ea25790a2f5cb241e6af4c3a7ebd15e35c6
MD5 1e82f8ff646443a10e34609dc965823b
BLAKE2b-256 b0b710f8920e2f767d774bdd99c5170182f31d70042f4915e6a24eca07eb7761

See more details on using hashes here.

File details

Details for the file dbease-1.0-py3-none-any.whl.

File metadata

  • Download URL: dbease-1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for dbease-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22877a1d3f7fc859573171494044e04adf0a5afe0cebe78d6ab2d7d568d93552
MD5 f3de871df065259745e0eb3593d4cd4e
BLAKE2b-256 c668864991fa6c432a17a5b3ce781fd839122ce0a3da93c57c879c47736fa635

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page