diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-02 16:11:52 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-02 16:12:04 +0000 |
commit | 25180730194bec25f915f32ab846ea583fb1493f (patch) | |
tree | 9a73e0336ecf21e085d99d6a651c5547b9eb99f8 /sources/pyside2/doc/tutorials/portingguide/chapter1/chapter1.rst | |
parent | 6e3e7b9ca0548430aaa5e2555d6e02c64625fa3f (diff) |
Rename PySide2 to PySide6
Adapt CMake files, build scripts, tests and examples.
Task-number: PYSIDE-904
Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/doc/tutorials/portingguide/chapter1/chapter1.rst')
-rw-r--r-- | sources/pyside2/doc/tutorials/portingguide/chapter1/chapter1.rst | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/sources/pyside2/doc/tutorials/portingguide/chapter1/chapter1.rst b/sources/pyside2/doc/tutorials/portingguide/chapter1/chapter1.rst deleted file mode 100644 index 20b11065a..000000000 --- a/sources/pyside2/doc/tutorials/portingguide/chapter1/chapter1.rst +++ /dev/null @@ -1,89 +0,0 @@ -Chapter 1: ``initDb.h`` to ``createDb.py`` -******************************************* - -To begin with, port the C++ code that creates an SQLite -database and tables, and adds data to them. In this case, -all C++ code related to this lives in ``initdb.h``. The -code in this header file is divided into following parts: - -* ``initDb`` - Creates a db and the necessary tables -* ``addBooks`` - Adds data to the **books** table. -* ``addAuthor`` - Adds data to the **authors** table. -* ``addGenre`` - Adds data to the **genres** table. - -To start with, add these following ``import`` statements at -the beginning of ``createdb.py``: - -.. literalinclude:: createdb.py - :language: python - :linenos: - :lines: 40-44 - -The ``initDb`` function does most of the work needed to -set up the database, but it depends on the ``addAuthor``, -``addGenre``, and ``addBook`` helper functions to populate -the tables. Port these helper functions first. Here is how -the C++ and Python versions of these functions look like: - -C++ version ------------- - -.. literalinclude:: initdb.h - :language: c++ - :linenos: - :lines: 55-81 - -Python version ---------------- - -.. literalinclude:: createdb.py - :language: python - :linenos: - :lines: 44-65 - -Now that the helper functions are in place, port ``initDb``. -Here is how the C++ and Python versions of this function -looks like: - -C++ version ------------- - -.. literalinclude:: initdb.h - :language: c++ - :linenos: - :lines: 81-159 - -Python version ---------------- - -.. literalinclude:: createdb.py - :language: python - :linenos: - :lines: 65- - -.. note:: The Python version uses the ``check`` function to - execute the SQL statements instead of the ``if...else`` - block like in the C++ version. Although both are valid - approaches, the earlier one produces code that looks - cleaner and shorter. - -Your Python code to set up the database is ready now. To -test it, add the following code to ``main.py`` and run it: - -.. literalinclude:: main.py - :language: python - :linenos: - :lines: 40- - -Use the following command from the prompt to run: - -.. code-block:: - - python main.py - -Your table will look like this: - -.. image:: images/chapter1_books.png - -Try modifying the SQL statment in ``main.py`` to get data -from the ``genres`` or ``authors`` table. |