python – Covid Tracker + Notify people = Ideal for small coffee place or similar

This is my second project since I started with Python, this time I learned a little bit of SQL that is so useful and beautifully simple.

Starting idea: Generate a program that will store information in DataBase(SQL).
Goal: Learn SQL basics and expand my knowledge in Python.
After project thoughts: The more basic it look the most difficult to find the BUG in the code. Spent 1 week finding a bug to finish the project and it was a variable repeated in two for loops.

Code purpose: During this time in the world I’ve seen a lot of paper used to do this job while at the same time they use a computer or tablet to charge you or book you in. What if we get rid of the paper and we only use digital?
This is supposed to be used by the employee not the user. Any confirmed case will be searched and this will allow you to send an email to all the people that were in the same place at the same time or +1 hour.

Really happy I hope yous like it, I know it needs Validation of User Input I tried to focus more on the PEP8 and mixture between Python and SQL.

Will appreciate any recommendations. Thank you.


import sqlite3
import datetime
import time
import smtplib
import imghdr
from email.message import EmailMessage

conn = sqlite3.connect('covid.db')
c = conn.cursor()

notify_group = list()

def enter_data():
    def create_table():
        c.execute('''CREATE TABLE IF NOT EXISTS
        name TEXT,
        email TEXT,
        ph_number INTEGER,
        datestamp TEXT,
        keyword TEXT)''')

    i_name = str(input('Please insert FULL NAME : n ...'))

    i_email = str(input('Please insert EMAIL : n ...'))

    i_number = int(input('Please insert PHONE NUMBER : n ...'))

    print('Your data has been saved for acelerated contact, thank you. n')

    def data_entry():
        date, keyword = dynamic_data_entry()
        c.execute('''INSERT INTO covidTrack
        VALUES(?, ?, ?, ?, ?)''', (i_name, i_email, i_number, date, keyword))

    def dynamic_data_entry():
        keyword = 'nameofvenue'
        date = str(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
        return date, keyword

    def read_from_db():
        c.execute('''SELECT * FROM covidTrack''')


def data_search():
    x = input('''Select desired search: n
    Search by FULL NAME. n

    if x.lower() == 'full name':
         specify_name = input('Please insert full name. n ')
         select_query = c.execute('''SELECT * FROM covidTrack WHERE NAME ==(?) ''', (specify_name,))
         for row in c.fetchall():
             print('Name:', row(0))
             print('Email:', row(1))
             print('Phone Number:', row(2))
             print('Date and Time:', row(3))
             print('Venue:', row(4))
             c.execute('''SELECT *
             FROM covidTrack
             WHERE datestamp >= ?
             AND datestamp <= datetime(?, '+1 hours')  ''', (row(3),row(3)))
             print('Matching Results: n ')

             for row2 in c.fetchall():

             add_people = input('Would you like to notify this group?Y/N')

             if add_people.lower() == 'y':
                 print('All the people in this search has been advised.')
             if add_people.lower() == 'n':

    if x.lower() == 'date and time':
        specify_datestamp = input('''Please insert full date as shown.
        Please follow this format...
        YYYY-MM-DD HH:MM:SS ''')

        c.execute('''SELECT * FROM covidTrack WHERE datestamp == ? ''', (specify_datestamp,))
        for row in c.fetchall():
             print('nName:', row(0))
             print('Email:', row(1))
             print('Phone Number:', row(2))
             print('Date and Time:', row(3))
             print('Venue:', row(4))
             d = row(3)

             c.execute('''SELECT *
             FROM covidTrack
             WHERE datestamp >= ?
             AND datestamp <= datetime(?, '+1 hours')  ''',(d,d))
             print('Matching Results: n')
             for row2 in c.fetchall():

    if x.lower() == 'exit':

def SendMail():
    msg = EmailMessage()
    msg('Subject') = 'covidTrack notification.'
    msg('From') = '#############'
    msg('To') = notify_group
    msg.set_content('It has been confirmed that you were a close contact in. Please contact us as soon as possible.')


    with open('covidTrackNotification.png', 'rb') as f:
        file_data =
        file_type = imghdr.what(
        file_name =
    msg.add_attachment(file_data, maintype='image', subtype=file_type, filename=file_name)

    with smtplib.SMTP_SSL('', 465) as smtp:
        smtp.login('###########', '#######')


def menu():
    choose_funtion = input('''Please choose action: n
    EXIT n ''')

    if choose_funtion.lower() == 'a':
        print('You choose enter data.')
    if choose_funtion.lower() == 'b':
        print('You choose search data.')
    if choose_funtion.lower() == 'exit':

Cheap Web Hosting For Small Business – $7/Year

Thumbs Up 

For small business website owners, picking a cheap but reliable hosting provider is vital. Your choice of picking such hosting provider will have a large impact on revenue and customer satisfaction, Raisinghost likes introduce with our budget yet quality web hosting plan starting from half dollar per month and we are sure that its the best plan in segment cheap web hosting for small business. We offer unlimited space and bandwidth with our basic hosting plan too and have higher resources included inode numbers.

Our plan offers you the freedom to send maximum emails per hour also having no limitation for the max connection for site and databases, we also allow remote mysql connections, these features can help to grow rapidly.

Coupon Code : SPECIAL50

Our service includes below features :

Full Access, standard web hosting
cPanel with all features
On Demand SSH Access
Server Location: Central USA
Setup fee: Free
Instant activation right after making payment
Daily Backups
Free Account migration.
Softaculous Auto installer
99.9% Uptime guarantee
24/7/365 support
30-Day Money Back Guarantee
Payment option: Paypal, Card Payment
Coding Assistance for premium plans

Thank you.

Fast international WP hosting for small site

I have a small wordpress website, <4k monthly visitors, serving about 2 MB per page, total 8 pages.

It is a hotel website so it is i… | Read the rest of

compiler – Small confusion about time complexity

Big-O notation is about identifying the term that grows the fastest.

It doesn’t matter if the constant out the front is huge, or tiny. Its a constant and does not change how quickly a term grows.

eg: 1/123456789 * N^3 + 123456789 * N^2 + 300000000000000000000 * N

In the smaller values of N the linear term is dominant. But it is quickly over taken by the N^2 term, and that term itself is overtaken by the N^3.

As N gets large the behaviour of the function always tends toward the quickest growing term. this is why the example is gave is O(N^3) even though for small values of N it behaves more quadratically on linearly. In your example its why its O(nlogn).

Is a Non-Clustered index needed when referencing a small table with a Foreign Key

I’m not a DBA, excuse me if this question sounds dumb. Hope I can get help from an experienced DBA, because I’m questioning this for a long time.

Assume there are 2 tables, one table with a lot of records, and one table is just static data with 2 records (for example: a Yes/No table).

As example take these 2 tables:

  • Table_Yes_No (only 2 records: Yes and No. Of course they have an incrementing clustered PK)
  • Table_Form (Very big table with lots of records, and one column has FK to the PK of Table_Yes_No).

Now my question; Is it worth putting an index on the FK (reference from Table_Form to the Table_Yes_No table)? The column will only contain 1 or 2 (but not sorted, because no index). Is it worth indexing such a FK?

An example in SQLFiddle:!18/51614/3/0

That column will be queried anyway, the question is will the index help the performance or not.

Does running a virtual machine provide a small layer of protection against an infected host in practice

Obviously a host can modify a virtual machine in any way and has full control over it, but in practice perhaps most viruses wouldn’t have the complexity to search for virtual machines and modify them. Although simple keyloggers I assume would still remain a threat.

What is cost of building small datacenter?

What can it cost in germany for example to build a mini data center with 46 or 2 x 46 Rack space?… | Read the rest of

array – Do C++ compilers optimize/pack small data types (e.g. boolean values)?

This occurred to me when looking at stencil computations in numpy. This python library compiles compute-intensive components, so I believe that it’s a valid example. Here making selections on an array is done with small offsets (0, 1, -1) a lot of times. Would a c++ compiler take into account that it doesn’t need a full integer/char/bool type and “pack” bits into bytes?

For example, could selecting every second element from 0 to 7, be represented as a single byte instead of 8 bytes:


instead of









ssh – how to generate a small RSA key

I want to “ssh-keygen -t rsa -b 512” but obviously my linux is too upto date to allow this, is there anyway to modify the settings to:

  1. generate a 512 key
  2. let me authenticate to the server with that 512 key

Yes I know its bad security practice but I am actually doing some security research, this server will be burnt and has nothing of value. this is pure research

scalability – Start small – but design in such way that sharding is possible – how?

Following question is more about best-practices than a real problem – nevertheless, I’d like to know how to do it in best way.

Given a service, that can operate in multiple countries/geo-areas, one probably start simple before even scaling is needed. A design would contain a single DB and single piece of infrastructure. An API endpoint(s) would look like this:


Now imagine that service grew a lot, and there is a need to create separate piece of infrastructure per each country/geo-area where our service operates. Would you do:

Option 1)

Stay with above API format, and route to shards based on queryString param from api url?

Option 2)

Create new API endpoints that have country/geo-area in url, e.g. /.../xyz/v1/items&page=1&size=100

Option 3)

Put country/geo-area to server part of url, e.g.

I see that Option 1) has a pros of not breaking contracts. But I’m not sure that routing based on queryString is good idea at all.

Option 2) a 3) breaks previous API contracts (clients that uses it must update) and it forces clients to react on server’s infrastructure changes, which is also a design-smell in my opinion.

Designing for sharding from very beginning is also not an option, as you don’t know if you ever need it.