Code Monkey home page Code Monkey logo

pyqt-database-example's Introduction

pyqt-database-example

PyQt database (SQLite) basic use example

I've stopped updating this, see "See Also" below and check the pyside-database-chart-example. I'm currently working on that one instead of this.

But you can still look through this and help yourself as well. This works like a charm.

Requirements

  • PyQt5 >= 5.12

Because one of QSortFilterProxyModel's function(setFilterRegularExpression) requires at least 5.12. This is indeed very convinient function so you don't have to worry.

Also you can use this in PyQt6 or PySide6, if you change all of "import PyQt5" in whole repo.

Setup

python -m pip install git+https://github.com/yjg30737/pyqt-database-example.git --upgrade

Feature

  • Add/delete record (one record at a time)
  • Search the text by each column
  • Set by ascending/descending order (ascending order by default)

Example

Code Sample

from PyQt5.QtWidgets import QApplication
from pyqt_database_example import createConnection, initTable, addSample, QtDatabaseExample

if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    if not createConnection():
        sys.exit(1)
    initTable() # Create table. After create table, you don't need to do it unless you want to make the table to empty.
    # addSample() Add sample records (Joe, Lara, David, Jane. See result image below.)
    ex = QtDatabaseExample()
    ex.show()
    sys.exit(app.exec_())

image

If you execute the script, "contacts.sqlite" SQLite database file will be made.

Result

image

'contacts' is table's name.

You can search the text with search bar. (instant search)

You can also set the column to search with combobox which is placed right next to search bar.

Add button literally adds new empty record.

Delete button deletes selected row. (Only one row can be selected currently)

Search bar example

Let's set the column to search as "Name" and search the text "Dav".

image

See Also

pyqt-database-example's People

Contributors

yjg30737 avatar

Stargazers

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