Monday, February 11, 2019

Reading From Database Using Python

After inserting the records into our database table, it is only expected that we should read from the table using our Python code.

Our database table EMPLOYEE looks like this:

You can display ALL the entries of your table below:

The fechall() will actually read all the records from your table. Using the loop, each of the record will be displayed.  The row[0], for instance, acts as the variable to hold the value of the first field(using our table above, First_Name), and row[1] will be be for our field Last_Name.

Don't forget that the Python code above is a function. If you don't have a main menu, then, simply call this module by typing, read( ), in your main code.

To search and display a specific record from the table, your Python code should be like this. You can double click to enlarge the photo.

Now, try this on other tables you have!

Wednesday, February 6, 2019

Database Programming using Python

I finally decided to go back to blogging to at least maximize the payment I made on the domain name and help out my students in their Python coding.

So, I have to start it by writing some codes to enable insertion of a record to a database I have made using XAMPP SQL.

For the sample database I created, see below:

You have to create this database and the tables before you create your front-end code using Python. Make sure though that you install the needed database connector for your OS and Python version. In my case, I'm using Python 3.4 using Windows 10.

Now for us to insert a record, you can try the Python code below.

Now the username and password of your database is dependent on whether you have set this during SQL installation.  If none, then leave these parameters blank.  I have used SCHOOL for my database

Dont forget that we have installed the db connector earlier, so, to connect our Python with XAMPP sql, then we need IMPORT MYSQL.CONNECTOR.

CURSOR( ) is used to allow Python  to execute SQL commands during database session. With this we can insert, select, update, delete records with our database

Now, dont forget your SQL to insert into the needed field names. If you forgot this, go back to your XAMPP and check your table structure to see the field names and their data types.

The INSERT record program above allows you dynamic session. So, you can prompt your user for any input and with these inputs, we store them to our database.

I have called this function using a menu. Once, you have created all other operations like VIEW, UPDATE, DELETE, then, we can all call them using our menu interface.

To see if your code is working, run it and make sure that you shift to your XAMPP to see if the new record is added. See below:

Now, it's your turn!

Saturday, November 25, 2017

Bina Bangsa School Teachers Support Charity Run Fest 2017

In the Philippines, I used to race competitively but I shall always be grateful that I have my Team Matutum teammates with me to race and have fun together.

So, I could only be happier that I am now in Indonesia teaching in a good school school with good people around. And, to do your passion for running with your  new running group, mine is the Solemates, I could only be grateful everyday.

Before the end of 2017, my fellow teachers were able to run in three different races, latest was the Charity Run for Cancer Patients where around 117 millions rupee were collected from the race. Having  a father stricken with cancer, the run is somehow personal and inspiring to me.

Teachers of Bina Bangsa School - PIK  post - race

Thirty teachers, both from primary and secondary departments,  from Bina Bangsa School - PIK joined other runners in 5KM and 10KM distances.

my fellow teachers - solemates running for cancer patients

With a worthy cause, we couldn't only be proud that we were able to support the run and have fun at the same time. We look forward then to more races in the future with worthy advocacy. 
winning 2nd placer from 10km female category

Now, did I mention that I won, 2nd place in the 10km female category? I was just lucky though!

So, congratulations to the organizers of Charity Run Fest 2017 and to Bina Bangsa School - PIK teachers for one good race, one good cause!

Thursday, March 30, 2017

Music: Help You Study for Exam

Final Examination is just around the corner and just recently I had to help some students with their ICT practical as they had their Final Exams in IT. I can't help but at least be worried with them as they cram for their exams.

The idea is to prepare in advance with all the resources, and support groups (teachers, family or studymates). But, you can do better if you have a timetable and strictly follow it and have quality study time.

photo source:

Equally important is the fact that you can use music to help you focus and concentrate.  University research in France, published in Learning and Individual Differences,  found out that students who listened to one-hour music while listening to classical music scored better in their quiz than students who don't.

They say that music can get you to heightened emotional state that makes you more receptive to information. Furthermore,  according to a research from Duke Cancer Institute, music can help lessen the anxiety.

Music help you relax; so, while preparing for your exam, listen to classical music and with crown xls1000 can help you enjoy the music as you focus on your exam.

It is only through hard work, quality reviews, and the right resources can help you get better marks.


Studying for Finals? Let Classical Music Help You