This microservice can help with search phone numbers in the database. First script, using Alembic, adds new column in the orders table. Second one, using phonenumbers library normalizes phone numbers and save them in the new column. It runs in the background, awaits new orders and updates rows.
Python 3 and libraries from requirements.txt should be installed. Use virtual environment tool, for example virtualenv.
virtualenv virtualenv_folder_name
source virtualenv_folder_name/bin/activate
python3 -m pip install -r requirements.txt
Put all necessary parameters to .env file.
PG_URL=postgresql://user:paswprd@host:port/database
PG_TABLE=postgresql_table
- Run add_column.py.
$ python add_column.py
-
Check if table has new column.
-
Run normalize_phone.py.
-
Check if new column contains normalized phone numbers.
The code is written for educational purposes. Training course for web-developers - DEVMAN.org