Python: подготовка к работе с БД MySQL

Я часто “переезжаю” от одного окмпа на другой и приходится с нуля настраивать энвайромент для работы с MySQL. В итоге я каждый раз смотрю видос Штукенции на эту тему (он будет внизу этой статьи), что не очень удобно, когда ты в сотый раз это делаешь. Решил сделать шпаргалку по Питону 🙂

Итак, допустим, у нас есть скрипт на Питон.

  1. Первым делом – устанавливаем сам Питон.
  2. Далее надо, чтобы скрипт открывался в IDLE. Для этого:

    – ПКМ на файл -> Open with… -> More apps… -> Look for another app… -> C:Python310Libidlelibidle.bat
  3. Также зайдем сразу в настройки IDLE и выберем там тёмную тему: Options → Configure IDLE → Highlights → жмяк на кнопку IDLE Classic → выбираем IDLE Dark
  4. Теперь обновляем Пип в CMD: py -m pip install --upgrade pip
  5. Ставим MySQL коннектор: pip install mysql-connector-python
  6. Наслаждаемся и пишем коммент к этомук посту 😉 А вот и видео с наглядным гайдом:

Читать

Python – loops (for, while, break, continue)

Loops in Python are pieces of code that repeat multiple times.

range(start,stop,step) – this is how the forLoop loop looks in general, where start and stop describe the actual beginning and end of the loop, including the start point, but not including the end point; step – the step with which the computer moves from the start point to the end point (another step is called increment).

Example:

range(1,10,2) means 1, 3, 5, 7, 9

Читать

Python – логические операторы и условия

Основные условия в Python:

  • < (одно меньше другого)
  • > (одно больше другого)
  • <= (одно меньше или равно другому)
  • >= (одно больше или равно другому)
  • != (одно не равно другому)
  • == (одно равно другому)

Примеры использования условий:

print(5 > 4)

True #результат

print(‘cat’==’dog’)

False #результат Читать

Python: Lists and Dictionaries

We continue to learn the Python programming language Python. We turn to the study of chapter 5 of the book: Michael Dawson “Programming in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where we will master lists, list methods and dictionaries.

Lists in Python

Lists are similar to tuples, which we studied in the last chapter. It’s important to remember that, unlike tuples, lists can change. The general principles for working with tuples apply to lists.

Читать

Python: lifehacks for setting up a programming environment

Once you’ve installed Python on your computer, it’s best to take care of the little nuances that make life easier for programmers. Let’s go through the basic settings of the programming environment and Windows for comfortable work:

1. Changing System Environment Variables

This setting will allow you to run a program written in Python in the CMD of the Windows operating system (command line interpreter). To do this, click “Start” -> Change system environment variables:

Читать

Python: лайфхаки по настройке среды программирования

Как только вы установили на компьютер Python, лучше сразу позаботиться о небольших нюансах, которые облегают жизнь программистам. Давайте пройдемся по основным настройкам среды программирования и Windows для комфортной работы:

1. Изменение системных переменных среды

Эта настройка позволит запускать программу, написанную на Python, в CMD операционной системы Windows (интерпретатор командной строки). Чтобы это сделать, нажимаем “Пуск” -> Изменение системных переменных среды: Читать