Let's create a customer database that automatically issues a QR code in Python

I went to a dry cleaner

The other day, I went to a nearby dry cleaner to take out my clothes under the direction of my wife.

Saturday after the new year.

Probably the day when the most customers will come.

However, there is one part-time lady there.

image.png

The customers are coming.

Well, that's right.

And, behind the customer, I'm back. .. I wonder if the phone rings insanely.

But I'm too busy to pick up the phone. ..

All humans are not good at multitasking

No human being can do this together.

image.png

~~ In the first place, is this a shift mistake of the store owner or the store manager? ?? ~~

I wondered if this situation could be dealt with by systematic improvement.

In the previous article, you can easily publish the QR code in Python. I wrote an article called, so it's an application.

Reference: Create QR code in Python. I don't want to line up because I write the same thing every time I issue a commuter pass. ..

Thing you want to do

・ When cleaning is completed, add a service to call, email, or SMS as an option. (It's impossible for everyone ~~ It's annoying ~~, so it's just an option) Put a QR code on your clothes and hold it over your smartphone so that you can contact customers by email, SMS, or phone.

・ The QR code will be automatically issued when the customer's information is registered. Simple management.

スクリーンショット 2020-01-12 15.12.34.png

Execution environment

Python 3.7.6 macOS Mojave 10.14.6

Import library

Import the required libraries first. (Install with pip if not included)

・ Qrcode for QR code creation ・ Datetime to enter the date and time at the time of customer registration ・ Csv for creating a database using CSV

customerdata.py


import qrcode
import datetime
import csv

Enter the necessary information when registering as a customer

Set to ask the customer database for the required information. Listen to the necessary information so that you can email, SMS, or call.

customerdata.py


name=input('Your name is?')
address=input('address?')
age=input('How old are you?')
tel=input('telephone number is?')
mail=input('Mail is?')

#Set the date and time to be registered in the database
dt_now=datetime.datetime.now()
dt=dt_now.strftime('%Y year%m month%d day%H o'clock%M minutes')

QR code creation

The QR code is set so that the name, phone number, email, address, and registration date and time are displayed. The name of the automatically issued img file is output by the person's name and phone number so that text search (by name and phone number) can be performed later.

customerdata.py


img=qrcode.make( 'phone number: ' + str(tel) +'Email: ' +str(mail)+'Full name:'+str(name)  + 'Street address:'+ str(address)+'Creation date and time:'+ str(dt))
img.save(str(name)+str(tel))

#Register the QR code name with your name and phone number so that you can search the text later.

Database registration

Register information in CSV. (Customer_data.csv)

customerdata.py



with open('customer_data.csv','a') as f:
    writer = csv.writer(f)
    #The next line is for initial registration only. Comment out when registering for the second time or later! !!
    writer.writerow(['Full name','age','Street address','phone number','Email','Registration date'])
    writer.writerow([str(name),str(age),str(address),str(tel),str(mail),str(dt)])
    f.close()
  

Run it on the command line.

commandline


(kyoto) MacBook-Air% python3 customerdata.py
Your name is?Taro Tanaka
address? Kyoto City A Town B Street
How old are you? 40
telephone number is? 090-000-0000
Mail [email protected]

Registered in the database like this.

スクリーンショット 2020-01-12 11.48.43.png

At the same time, a QR code will be issued automatically. スクリーンショット 2020-01-12 11.50.14.png

Information will come out when you hold it over your iPhone and read the QR code.

IMG_2287.PNG

Source code

customerdata.py




import qrcode
import datetime
import csv

name=input('Your name is?')
address=input('address?')
age=input('How old are you?')
tel=input('telephone number is?')
mail=input('Mail is?')


dt_now=datetime.datetime.now()
dt=dt_now.strftime('%Y year%m month%d day%H o'clock%M minutes')

img=qrcode.make( 'phone number: ' + str(tel) +'Email: ' +str(mail)+'Full name:'+str(name)  + 'Street address:'+ str(address)+'Creation date and time:'+ str(dt))
img.save(str(name)+str(tel))


with open('customer_data.csv','a') as f:
    writer = csv.writer(f)
    #The next line is for initial registration only. Comment out when registering for the second time or later! !!
    writer.writerow(['Full name','age','Street address','phone number','Email','Registration date'])
    writer.writerow([str(name),str(age),str(address),str(tel),str(mail),str(dt)])
    f.close()

It seems that it can be applied in various ways

Creating a database and automatically issuing a QR code can be applied in many other ways. Food delivery, prevention of wandering in elderly people with dementia, allergy and drug contraindications.

I would be grateful if you could give us comments that are expandable and expandable so that you can use it like this.

スクリーンショット 2020-01-12 15.12.34.png

Recommended Posts

Let's create a customer database that automatically issues a QR code in Python
Let's create a script that registers with Ideone.com in Python.
Create code that outputs "A and pretending B" in python
[Django] Create a form that automatically fills in the address from the zip code
In Python, create a decorator that dynamically accepts arguments Create a decorator
Create a function in Python
Create a dictionary in Python
Create a QR code that displays "Izumi Oishi" by scratch
[Python] Generate QR code in memory
Automatically format Python code in Vim
Create a binary file in Python
Let's create a program that automatically registers ID/PW from CSV to Bitwarden with Python + Selenium
Create a random string in Python
Create a Python environment for professionals in VS Code on Windows
Let's create a Python directory structure that you won't regret later
Create a simple GUI app in Python
Let's create a virtual environment for Python
Let's create a free group with Python
Create a JSON object mapper in Python
[Python] Create a LineBot that runs regularly
[GPS] Create a kml file in Python
Let's make a combination calculation in Python
[Python] I wrote a simple code that automatically generates AA (ASCII art)
Code reading of faker, a library that generates test data in Python
[Python] Based on your favorite desktop image, let's automatically create a terminal / Vim / VS Code theme that suits your feelings with one command.
Create a Vim + Python test environment in 1 minute
Create a GIF file using Pillow in Python
A memo that I wrote a quicksort in Python
I tried to create a class that can easily serialize Json in Python
I want to create a window in Python
Create a plugin that allows you to search Sublime Text 3 tabs in Python
I want to create a priority queue that can be updated in Python (2.7)
Create a standard normal distribution graph in Python
How to create a JSON file in Python
Automatically create word and excel reports in python
Create a virtual environment with conda in Python
Create a page that loads infinitely with python
A program that removes duplicate statements in Python
Let's look at a differential equation that cannot be solved normally in Python
Create a simple momentum investment model in Python
Python: Create a class that supports unpacked assignment
Create a new page in confluence with Python
A Vim plugin that automatically formats Python styles
Create a datetime object from a string in Python (Python 3.3)
Create a package containing global commands in Python
Create a MIDI file in Python using pretty_midi
Create a loop antenna pattern in Python in KiCad
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Create an exe file that works in a Windows environment without Python with PyInstaller
Create a data collection bot in Python using Selenium
[LINE Messaging API] Create a rich menu in Python
A collection of code often used in personal Python
Create a QR code for the URL on Linux
I want to write in Python! (2) Let's write a test
Let's write python code that parses go code and generates go code
A memorandum when writing experimental code ~ Logging in python
Create a plugin to run Python Doctest in Vim (2)
Use Cursur that closes automatically with sqlite3 in Python
Create a plugin to run Python Doctest in Vim (1)
What's in that variable (when running a Python script)
Create a fake Minecraft server in Python with Quarry