Friday, January 11, 2019

Update a Record Using Python and MySQL

A simple program that will show you how to update a record using Python and MySQL. I have a great time learning Python it is easy to so many  information that I can learn and get over the Internet.

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing


import pymysql

connection = pymysql.connect(
    host='localhost',
    user='root',
    password='',
    db='my_python',
)

print("")
print("UPDATE RECORD")
print("")
id1 = input("Enter users ID Number : ")
name1 = input("Enter users name : ")
age1 = input("Enter users age : ")
address1 = input("Enter users address :  ")
print("")
try:
    with connection.cursor() as cursor:
        sql = "UPDATE users SET name=%s, age=%s,address=%s WHERE id = %s"
        try:
            cursor.execute(sql,(name1.upper(),age1,address1.upper(),id1))
            print("Record Successfully updated in the database")
        except:
            print("Oops! Something wrong")

    connection.commit()
finally:
    connection.close()

Delete a Record Using Python and MySQL

Here is a code that will show and teach you how to delete a single record in Python and MySQL.

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing


import pymysql

connection = pymysql.connect(
    host='localhost',
    user='root',
    password='',
    db='my_python',
)

print("")
print("DELETE RECORD")
print("")

id = input("Enter users ID Number :  ")
print("")
try:
    with connection.cursor() as cursor:
        sql = "DELETE FROM users WHERE id = %s"
        try:
            cursor.execute(sql,(id))
            print("Record Successfully deleted in the database")
        except:
            print("Record not found")

    connection.commit()
finally:
    connection.close()

View Record Using Python and MySQL

A code that will teach you how to view records using Python and MySQL.  I am still a beginner in Python programming which I find it interesting to learn.

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

import pymysql

connection = pymysql.connect(
    host='localhost',
    user='root',
    password='',
    db='my_python',
)

try:
    with connection.cursor() as cursor:
        sql = "SELECT id,name,age,address FROM USERS ORDER BY ID ASC"
        try:
            cursor.execute(sql)
            result = cursor.fetchall()

            print("ID\t\t\tName\t\t\t\t Age\t\t\t\t\tAddress")
            print("---------------------------------------------------------------------------")
            for row in result:
                print(str(row[0]) + "\t\t\t" +row[1] + "\t\t\t" + row[2] + "\t\t\t" + row[3])

        except:
            print("Oops! Something wrong")

    connection.commit()
finally:
    connection.close()


Insert Record Using Python and MySQL

Here is a simple code that I wrote how to insert a record using Python and MySQL. The code is very simple and easy to understand.

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Program Listing

insert.py


import pymysql

connection = pymysql.connect(
    host='localhost',
    user='root',
    password='',
    db='my_python',
)

print("")
print("ADD RECORD")
print("")
name1 = input("Enter users name : ")
age1 = input("Enter users age : ")
address1 = input("Enter users address :  ")
print("")
try:
    with connection.cursor() as cursor:
        sql = "INSERT INTO users(name,age,address) VALUES (%s,%s,%s)"
        try:
            cursor.execute(sql, (name1.upper(),age1,address1.upper()))
            print("Record Successfully added in the database")
        except:
            print("Oops! Something wrong")

    connection.commit()
finally:
    connection.close()


Tuesday, January 8, 2019

Three Light Emitting Diode Running Lights in Arduino


In this article I would like to share with you a sample program that I wrote using C for Arduino to perform Three Light Emitting Diode Running Lights. The code is very simple and short I am still a beginner in Arduino Programming. I hope you will find my work useful. I used Microsoft Windows XP Service Pack 2 as my operating system, Arduino UNO and Arduino IDE in the development of this application.

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com







Sample Program Output


Program Listing

/* Three LED Blinkers
 *  Written By Mr. Jake Rodriguez Pomperada,MAED-IT
 *  Date : January 8, 2018      8:16 PM   Tuesday
 *  Bacolod City, Negros Occidental
 *  jakerpomperada@yahoo.com and jakerpomperada@gmail.com
 */

/* A simple program to sequentially turn on and turn off 3 LEDs */ 

int LED1 = 13;
int LED2 = 12;
int LED3 = 11;

void setup() {
   pinMode(LED1, OUTPUT);
   pinMode(LED2, OUTPUT);
   pinMode(LED3, OUTPUT);
}

void loop() {
  digitalWrite(LED1, HIGH);    // turn on LED1 
  delay(300);                  // wait for 300ms
  digitalWrite(LED2, HIGH);    // turn on LED2
  delay(300);                  // wait for 300ms       
  digitalWrite(LED3, HIGH);    // turn on LED3 
  delay(300);                  // wait for 300ms
  digitalWrite(LED1, LOW);     // turn off LED1
  delay(200);                  // wait for 200ms
  digitalWrite(LED2, LOW);     // turn off LED2
  delay(200);                  // wait for 200ms
  digitalWrite(LED3, LOW);     // turn off LED3
  delay(200);                  // wait for 200ms before running program all over again
}

Login Using a Text File in C

While I'm writing my book on C programming I came across with the idea to include in my book topic on File Handling in C.  The idea is to write a program using C as my programming language to store a username and password in a text file and create a login program that will ask the user to give the username and password. The program will search for the username and password that is already stored in our text file. In this example the name of the text file is users.txt. I

If the username and password are correct and can be located in the text file the program will allow the user to access the system. But if username or password is incorrect the program will not allow the user to access the system. I hope you will find my work useful.  Thank you.

I am currently accepting programming work, it projects, school and application development.


programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com





Sample Program Output


Program Listing

/* login.c 
 Author    : Jake Rodriguez Pomperada,MAED-IT 
 Website   : http://www.jakerpomperada.com
 Emails    : jakerpomperada@gmail.com and jakerpomperada@aol.com
 Location  : Bacolod City, Negros Occidental
 Tool      : Dev C++ Version 5.11
 Date      : January 7, 2019   3:46 PM Monday
*/

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>

void get_ID_and_PASS(char fileName[30],char *id,char *pass)
{
    FILE *F = fopen(fileName,"r");

    if(F)
    {
        int count = 0;
        while(!feof(F))
        {
            char rawLine[50];
            fscanf(F,"%s",rawLine);
            if(!count++)
                strcpy(id,rawLine);
            else
                strcpy(pass,rawLine);

        }
    }else printf("Cannot open this file");
    fclose(F);
}

int main()
{
    char fileName[30] = "users.txt";
    char userID[50],userPassW[50];
    char strID[50]="\0",strPASSW[50]="\0";
    char IDpref[50] = "user_id:\0",PASSWpref[50] = "password:\0";
    get_ID_and_PASS(fileName,userID,userPassW);
    char c;
    int pos = 0;
        printf("\n\n");
        printf("\tLOGIN SECURITY SYSTEM IN C USING TEXT FILES");
        printf("\n\n");
        printf("\tEnter User Name      : ");
        scanf("%s",&strID);
        printf("\n");
        printf("\tEnter Your Password  : ");
        do {
        c = getch();

        if( isprint(c) ) 
        {
            strPASSW[ pos++ ] = c;
            printf("%c", '*');
        }
        else if( c == 9 && pos )
        {
            strPASSW[pos--] = '\0';
            printf("%s", "\b \b");
        }
    } while( c != 13 );
        strcpy(strID,strcat(IDpref,strID));
        strcpy(strPASSW,strcat(PASSWpref,strPASSW));

        if (!strcmp(strID,userID)&&!strcmp(strPASSW,userPassW))
        {
            printf("\n\n");
            printf("\tCorrect Username And Password\n");
            printf("\n\n\tWelcome to the System\n\n"); 
        }
        else
        {
           printf("\n\n");
           printf("\tInvalid Username And Password. Try Again\n\n");
         }
     printf("\n\n");
     printf("\tEND OF PROGRAM");
     printf("\n\n");
     system("pause");
}


users.txt

user_id:admin
password:Jake123!@#



Sunday, January 6, 2019

12 LED's Running Lights in Arduino

In this article I would like to share with you a sample applications that I wrote using C in Arduino to perform 12 LED's Running Lights. The source code is very simple and easy to understand.

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com








Sample Program Output


Program Listing

/* A simple program to sequentially turn on and turn off 12 LED's
   Author : Jake R. Pomperada, MAED-IT
   January 6, 2019  Sunday
   Bacolod City, Negros Occidental, Philippines
   jakerpomperada@gmail.com and jakerpomperada@yahoo.com
*/ 

int LED1 = 13;
int LED2 = 12;
int LED3 = 11;
int LED4 = 10;
int LED5 = 9;
int LED6 = 8;
int LED7 = 7;
int LED8 = 6;
int LED9 = 5;
int LED10 = 4;
int LED11 = 3;
int LED12 = 2;



void setup() {
   pinMode(LED1, OUTPUT);
   pinMode(LED2, OUTPUT);
   pinMode(LED3, OUTPUT);
   pinMode(LED4, OUTPUT);
   pinMode(LED5, OUTPUT);
   pinMode(LED6, OUTPUT);
   pinMode(LED7, OUTPUT);
   pinMode(LED8, OUTPUT);
   pinMode(LED9, OUTPUT);
   pinMode(LED10, OUTPUT);
   pinMode(LED11, OUTPUT);
   pinMode(LED12, OUTPUT);
}


void loop() {
  digitalWrite(LED1, HIGH);    // turn on LED1 
  delay(200);                  // wait for 400ms
  digitalWrite(LED2, HIGH);    // turn on LED2
  delay(200);                  // wait for 400ms       
  digitalWrite(LED3, HIGH);    // turn on LED3 
  delay(200);                  // wait for 400ms
  digitalWrite(LED4, HIGH);    // turn on LED4
  delay(200);                  // wait for 400ms
  digitalWrite(LED5, HIGH);    // turn on LED5
  delay(200);                  // wait for 400ms
  digitalWrite(LED6, HIGH);    // turn on LED6
  delay(200);                  // wait for 400ms
  digitalWrite(LED7, HIGH);    // turn on LED7
  delay(200);                  // wait for 400ms
  digitalWrite(LED8, HIGH);    // turn on LED8
  delay(200);                  // wait for 400ms
  digitalWrite(LED9, HIGH);    // turn on LED9
  delay(200);                  // wait for 400ms
  digitalWrite(LED10, HIGH);    // turn on LED10
  delay(200);                  // wait for 400ms
  digitalWrite(LED11, HIGH);    // turn on LED11
  delay(200);                  // wait for 400ms
  digitalWrite(LED12, HIGH);    // turn on LED12
  delay(200);                  // wait for 400ms
  digitalWrite(LED1, LOW);     // turn off LED1
  delay(200);                  // wait for 400ms
  digitalWrite(LED2, LOW);     // turn off LED2
  delay(200);                  // wait for 300ms
  digitalWrite(LED3, LOW);     // turn off LED3
  delay(200);                  // wait for 400ms
  digitalWrite(LED4, LOW);     // turn off LED4
  delay(200);                  // wait for 300ms
  digitalWrite(LED5, LOW);     // turn off LED5
  delay(200);                  // wait for 400ms
  digitalWrite(LED6, LOW);     // turn off LED6
  delay(200);                  // wait for 400ms
  digitalWrite(LED7, LOW);     // turn off LED7
  delay(200);                  // wait for 400ms
  digitalWrite(LED8, LOW);     // turn off LED8
  delay(200);                  // wait for 300ms
  digitalWrite(LED9, LOW);     // turn off LED9
  delay(200);                  // wait for 400ms
  digitalWrite(LED10, LOW);     // turn off LED10
  delay(200);                  // wait for 400ms
  digitalWrite(LED11, LOW);     // turn off LED11
  delay(200);                  // wait for 400ms
  digitalWrite(LED12, LOW);     // turn off LED8
  delay(200);                  // wait for 300ms before running program all over again
}


Addition and Difference in Delphi

Here is a simple program to perform addition and subtraction in Delphi. I used Delphi 7 Enterprise edition in writing this program. 

I am currently accepting programming work, it projects, school and application development.

programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com




Program Listing

unit add_differece;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
   
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
var a,b : integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
a:= strtoint(edit1.text);
b:= strtoint(edit2.text);
label6.caption := 'The sum of ' + inttostr(a) + ' and ' +inttostr(b) + ' is ' +inttostr(a+b) + '.';
label7.caption := 'The difference of ' + inttostr(a) + ' and ' +inttostr(b) + ' is ' +inttostr(a-b) + '.';
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.text := '';
edit2.text := '';
label6.caption :='';
label7.caption :='';
edit1.SetFocus;

end;


procedure TForm1.Button3Click(Sender: TObject);
begin
    if MessageDlg('Do you want to quit this program?', mtConfirmation, [mbYes, mbNO], 0) = mrYes then
begin
form1.Close;
end
else
begin
edit1.SetFocus;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

end.