Adsense Ad

Saturday 28 March 2020

Python - Flask: ModuleNotFoundError: No module named 'MySQLdb'

When we try to communicate with our xampp server mysql this "ModuleNotFoundError: No module named 'MySQLdb' " is raised. Not to worry.

Just open your command line at type following command to install mysql client:
pip install mysqlclient

If you still can't install it and having some errors then visit Unofficial Python Libraries to download mysql-client and install it through wheel using following command

pip install <downloadedWheelLibraryName>

Wednesday 25 March 2020

Create custom color palette in Oracle Forms


Please follow the steps to generate custom color palette:

1.) Go to Tools->Preferences. On the Color Mode drop-down, select Editable. Ok



2.) Your way out of the box then exit Forms builder.

3.) Restart forms builder.

4.) Open up a canvas window, then go to Format->Layout Options->Color Palette.

Now you can select any color on the palette and edit it.

Oracle Forms: Drag And Drop

Here is a Java bean that allows to Drag 'n Drop between Forms items.



. Download the DnD.zip file
. Unzip the file
. copy the DnD.jar file in the <ORACLE_HOME>/forms/java directory
. Edit your /forms/server/formsweb.cfg file to add this jar file
. Open the DnD.fmb module (Oracle Forms)
. Compile all and run the module


Oracle Forms: Auto Complete Combo Box

Here is a Java Bean that allows to manage an "auto completion" Swing JComboBox.


. Download the CBAutoCompletion.zip file
. Unzip the file
. copy the ComboBoxCompletion.jar file in the <ORACLE_HOME>/forms/java directory
. Edit your /forms/server/formsweb.cfg file to add the ComboBoxCompletion.jar .
. Open the CBAUTOCOMPLETION.fmb module (Oracle Forms)
. Compile all and run the module
     The JAR file has to be signed.


Oracle Forms: How to center the windows of oracle forms

A very common issue we face that how we center our forms in Oracle Forms MDI Window. In order to track this issue, following code can be use in Form-Level Trigger WHEN-WINDOW-ACTIVATED

Declare
  v_Window Varchar2(1000) := 'MAIN';
  v_Width  Number(4);
  v_Height Number(4);
  v_MDI_Wth Number(4);
  v_MDI_Hth Number(4);
Begin
  Set_Window_Property(Forms_Mdi_Window, Window_State, Maximize);
  v_MDI_Wth := Get_Application_Property(Display_Width) - 50; 
  v_MDI_Hth := Get_Application_Property(Display_Height) - 140;

  v_Width  := Get_Window_Property(v_Window, Width);
  v_Height := Get_Window_Property(v_Window, Height);

  Set_Window_Property(v_Window,
  Position,
  (v_MDI_Wth - v_Width) / 2,
  (v_MDI_Hth - v_Height) / 2);

End;

Monday 23 March 2020

Python Flask: Calling a html page using FLASK

Templates are required for any web app. Therefore I create a folders in my Flask project named as "Templates" in which I will save all templates in .html file format. Also I used Sublime Text 3 to work on my Flask web. Sublime Text 3 is a very powerful and user friendly tool for development.

Now I create a "index.html" file in my templates folder with following code:
<!DOCTYPE html>
<html>
<head>
 <title></title>
</head>
<body>
 <h1>Hello! My Name Is Hasan Jawaid</h1>
          <p>This my first page</p>
            <p>Using Flask - Python</p>
</body>
</html>

Now I create a .py file using my PYCHARM IDE with following code:

from flask import Flask, escape, request, render_template

app = Flask(__name__)

@app.route('/')
def hello():
    return render_template('index.html')

app.run(debug=True)

Above code will call the hello() function which returns me index.html page. First render_template must be import from flask library in order to enable calling of .html page.


Sunday 22 March 2020

Flask Python: Basic web app

Before working on FLASK make sure the FLASK is successfully installed with PYCHARM IDE:

You can also use Window Powershell to install FLASK suing following command:
>> pip install Flask

Following is the basic code for developing a web app using FLASK Python:

from flask import Flask, escape, request

app = Flask(__name__)

@app.route('/')
def hello():
    name = request.args.get("name", "World")
    return f'Hello, {escape(name)}!'
@app.route('/hj')
def hj():
    return 'Hello HJ hj'

app.run(debug=True)

@app.route('/')
On web loading, above line route on home page of your app

@app.route('/hj')
Above line route to hj page of your app


Oracle PL/SQL: Split Comma Separated String (CSV)

I developed a function in Oracle PL/SQL. By which we can split comma separated string and can pick string by just defining its position.

Following is the code of the function:

Create Or Replace Function Split_Csv_Text(Text Varchar2, Position Number)
  Return Varchar2 Is
  Res Varchar2(4000);
Begin
  Res := Regexp_Substr(Text, '([^,]*)(,|$)', 1, Position, Null, 1);
  Return Res;
Exception
  When Others Then
    Res := Sqlerrm;
    Return Res;
End;


Another function in Oracle PL/SQL, which is also able to split string but in this function we can defined any separator which its not only dependent on "," comma only.

Create Or Replace Function Split_Text_Deli(p_String  In Varchar2,
                                           p_Element In Number,
                                           p_Delim   In Varchar2 Default ',')
  Return Varchar2 As
  v_String Varchar2(32767) := p_Delim || p_String || p_Delim;
Begin
  Return Substr(v_String,
                Instr(v_String, p_Delim, 1, p_Element) + Length(p_Delim),
                Instr(v_String, p_Delim, 1, p_Element + 1) -
                Instr(v_String, p_Delim, 1, p_Element) - Length(p_Delim));
End Split_Text_Deli;

Saturday 21 March 2020

Oracle Forms: Sticky Cursor / Cursor Stuck in Master-Detail Form


Sometimes cursor is stuck in Master-Detail Form. Due to this issue we are unable to navigate using mouse clicks. I find out the following "WHEN-MOUSE-CLICK " trigger on Form-Level can handle the sticky cursor problem easily.

--Form Level Trigger = WHEN-MOUSE-CLICK 
Begin
  If Get_Item_Property(:System.Mouse_Item, Item_Type) Not In ('BUTTON', 'DISPLAY ITEM') Then
    If :System.Trigger_Block <> :System.Cursor_Block Then
      Go_Block(:System.Trigger_Block);
    End If;
    If :System.Mouse_Record <> :System.Cursor_Record Then
      Go_Record(:System.Mouse_Record);
    End If;
    If :System.Mouse_Item <> :System.Cursor_Item Then
      Go_Item(:System.Mouse_Item);
    End If;
  End If;
End;