How to connect Pydroid 3 and SQL database|Learn to code in android|How to run python on android and connect database|How to connect python and sql database in android|How to connect Sql lite database and python

Introduction

This is a Pydroid3 tutorial in which we are going to learn about connecting SQLite databse with python on Android.
In this Tutorial You are How can you use SQL queries on pydroid app?
as well as Connect MySQL with Python in Your Android Phone


Pydroid3:-

My experience

Earlier it was difficult for users to code python ,Especially for android users,as their was huge lack of such IDE's.Development of these application made it easier for everyone to learn python and coding.

I would recommend this apk because i have used it and I personally had a good experience about it.

About Apk

Pydroid 3 is an easy to use powerful Python 3 IDE for Android.You can run Python programs using this apk on Android.It is available on Almost all the App stores including Play store.This comes with many preinstalled libraries plus have a large collection of installable libraries and modules.

It comes with a terminal mode.Also it has many user friendly and user customizable settings.

You will get more information about it on playstore.
In present Date ,Their are many IDE'S which provide you similar type of service.
Some examples are 'QPYTHON3L'.....etc.

If you want to Know which one should you prefer, Then i will recommend you to visit this post:-https://learntechpython.blogspot.com/2021/05/how-to-run-python-on-android-devices.html


Database:-

A  standard definition database is that , it is an organized collection of data,so that it can be easily accessed and managed.

The main purpose of a database is to operate a huge amount of information by storing,retrieving,and managing data.It is done by using special commands or language known as SQL("structured query language")

Some examples of present day databases are MySQL, SQLite,Oracle, etc.They are managed by Database Management System also known as DBMS.


In this tutorial I have used SQLite3.

Following are the Steps To connect python and Sql database are:


1)Importing Library
2)Connecting to database
3)Creating a Cursor object
4)Writing a query
5)executing the query
6)saving the change using "commit()" if it is DML or TCL command(query)

Note:- You can perform 4th and 5th step at a time by directly writing the query inside c.execute()

Following is a sample code with a YouTube Tutorial in last.

Python Code:-

import sqlite3

con=sqlite3.connect('NEWDATABSE.db')

c=con.cursor()

query1=("CREATE TABLE FIRST(COLUMN1 text, COLUMN2 text)")

c.execute(query1)

query2=("insert into FIRST(COLUMN1,COLUMN2) VALUES ('TRIAL1','SUBSCRIBE')")

c.execute(query2)

con.commit()

#--------------------CODE ENDED    ---------------

ABOUT THE CODE:-

If the database is not created then it will create a new database file with the following name. If the database file already exists then it will get connected to the existing database file.In order to connect existing database file you have to paste the path of your file in the place of "NEWDATABSE.db" in line 2 of the code.
You can execute any query that you want by simply writing the query i the place of "query1" and "query2".

NOTE:-We have to create column only once(query1).If executed More than once then it may cause an error.

For better understanding you may watch my following tutorial.


YOUTUBE TUTORIAL

After Watching the video:-

I have used pydroid for executing the code ....YOU CAN USE ANY SOFTWARE OR APPLICATION THE  SOURCE CODE WILL BE SAME.

I USED:-
1)SQLite(DBMS)
2)PYDROID(for running the code on android)
3)Sqlite3(library)
4)SQLite editor(for checking the execution....AVAILABLE ON PLAYSTORE)


Where you can use this established connection:-

To Understand about uses of the established the connection first we need to understand the purpose of this establishment.

When we have to perform certain application where we need to store Huge amount of data which we can't store in variables.When we store them in database then it becomes easier to retrieve them.One more advantage is that its arranged in a very sorted manner.

Now coming to its uses, We generally use it in Projects where the user enters the data using Python and retrieves the data using Python. But what actually happen in the backend is that python is first retrieving the data from the stored content(data) of DBMS and just showing it to us.It means that our program involves both A Front-End and a Back-end processing.
For example, if we consider about functions of BANK MANAGEMENT application.. We can see that the information is taken by us and stored in their Database, AND when they need our data then it is retrieved from the stored database..Similar can be said in context of updating our data.

Can we Use it with GUI ?:-
So the Answer is Yes.The question is very basic but it's necessary to clear all the things I can .
GUI(Graphical user interface):-Its basically a system of interactive visual components for a software. A GUI displays objects that convey information, and represent actions that can be taken by the user. In simple words it is just representation of the code for user with proper arrangements of widgets.
We need to understand that it does not affect the working of the program.It's only function is to manage how things are going to display.That's it.

Conclusion
So in this Blog we learnt that how to use Pydroid3 with Sql database.

"HOPE IT HELPED"

Have anything in mind? Let me 
know in the comment section👇

Next Post
No Comment
Add Comment
comment url