Open links in new tab
  1. Data Management With Python, SQLite, and SQLAlchemy

    Python Database Tutorial - GeeksforGee…

    In this tutorial, we will focus on how to use Python with the most commonly used databa…

    GeeksForGeeks
    Mastering Python Data Handling: A Comprehe…

    This guide is here to walk you through the basics of python data handling, from setting up your wo…

    https://www.datascienceexpertise.com/mastering-python-data-handling-a-comprehensive-guide
  1. Managing data in Python can be done using flat files (CSV, JSON) or databases like SQLite with SQLAlchemy for ORM-based access. Below is a concise example using SQLite and SQLAlchemy to store, query, and update structured data.

    from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, func
    from sqlalchemy.orm import declarative_base, relationship, sessionmaker

    # Define ORM base
    Base = declarative_base()

    # Define models
    class Author(Base):
    __tablename__ = "author"
    author_id = Column(Integer, primary_key=True)
    first_name = Column(String)
    last_name = Column(String)
    books = relationship("Book", back_populates="author")

    class Book(Base):
    __tablename__ = "book"
    book_id = Column(Integer, primary_key=True)
    title = Column(String)
    author_id = Column(Integer, ForeignKey("author.author_id"))
    author = relationship("Author", back_populates="books")

    # Create SQLite DB and session
    engine = create_engine("sqlite:///library.db")
    Base.metadata.create_all(engine)
    Session = sessionmaker(bind=engine)
    session = Session()

    # Insert data
    author = Author(first_name="Stephen", last_name="King")
    book1 = Book(title="The Shining", author=author)
    book2 = Book(title="It", author=author)
    session.add_all([author, book1, book2])
    session.commit()

    # Query data
    results = session.query(Author.first_name, Author.last_name, func.count(Book.title).label("total_books"))\
    .join(Book)\
    .group_by(Author.author_id)\
    .all()

    for first, last, total in results:
    print(f"{first} {last} has written {total} books.")

    # Update data
    book_to_update = session.query(Book).filter_by(title="It").first()
    book_to_update.title = "It (Updated Edition)"
    session.commit()

    # Delete data
    book_to_delete = session.query(Book).filter_by(title="The Shining").first()
    session.delete(book_to_delete)
    session.commit()
    Copied!
    Feedback
  2. Python Database Tutorial - GeeksforGeeks

    Jul 23, 2025 · In this tutorial, we will focus on how to use Python with the most commonly used databases: MySQL, SQLite, and MongoDB. We will cover how to connect to these databases, run …

  3. Mastering Python Data Handling: A Comprehensive Guide …

    This guide is here to walk you through the basics of python data handling, from setting up your workspace to cleaning and analyzing your information. We’ll cover …

  4. Mastering SQLAlchemy: A Comprehensive Guide for …

    Nov 6, 2024 · From building APIs to creating content management systems and performing data analysis, SQLAlchemy provides a powerful and flexible foundation …

  5. Data Management in Python — Introduction to Python and SQL for …

    Data Management in Python Now that we can access our data within Python, we might want to do something cool, like creating visualizations, or making predictions. Before we do all that, though, we …

  6. Python for Databases: Learning Data Management with Python - Udemy

    In this course, you will learn all about relational database management systems and non-relational systems. By the end of this journey, you will gather essential skills to work confidently with various …

  7. People also ask
    Loading
    Unable to load answer
  8. Data Science with Python Tutorial - GeeksforGeeks

    Mar 3, 2026 · Data Science with Python focuses on extracting insights from data using libraries and analytical techniques. Python provides a rich ecosystem for …

  9. Learn Python for Beginners, Python Basics Course

    The first half of this course prepares you to use Python interactively and teaches you how to store, access, and manipulate data using one of the most popular …