I need to make an application that uses database in python

In summary, you are looking to make an application that uses a database in python but are unsure of what to make. You have some basic knowledge of python and are considering using Django. You are interested in projects such as a todo app and are wondering if it would use a database. You have also looked into databases such as SQL and are considering using a python module that follows the database API specification 2.0. You will need to install a database to connect to and can use code to read records. Some tutorials for MySQL and PostgreSQL are provided as well as information on using Django to define python classes for a project.
  • #1
shivajikobardan
674
54
I need to make an application that uses database in python, what should I make?

Firstly I need to tell about me. I know 0 about programming. I have learned basics of python only. What are the apps that use database that are upto my level of programming?

I am planning to use django.
-------------------------------------------
Softwares that I love to make-:

1) There is a website called slideplayer.com. I want to download the slides of that page as images and convert them to pdf. Is this doable in my level of programming? Does this uses database? What do I need to learn to make this type of application?

-------------------------------------------
What are doable projects of my level? Please guide a bit? I am thinking about todo app. Is that doable on my level? What do I need to learn to be able to make a todo app in django?
 
Technology news on Phys.org
  • #2
Pick something you like that has information associated with it:
popular music: title, artist, lyricist, genre, rating, ...
photographs: title, location, f-stop, shutter speed, zoom setting, ...
TV shows: title, broadcast network, genre, ...
Cooking: ...
Exercise: ...
...

Write a program to store and look up this information.
Or you could make a database program that holds the list of possible database projects that I started above. :cool:
 
Last edited:
  • Like
Likes Janosh89, BvU and anorlunda
  • #3
FactChecker said:
Pick something you like that has information associated with it:
popular music: title, artist, lyricist, genre, rating, ...
photographs: title, location, f-stop, shutter speed, zoom setting, ...
TV shows: title, broadcast network, genre, ...
Cooking: ...
Exercise: ...
...

Write a program to store and look up this information.
Or you could make a database program that holds the list of possible database projects that I started above. :cool:
Is todo app project fine, does it uses database? I think so?
 
  • #4
shivajikobardan said:
Is todo app project fine, does it uses database? I think so?
Sure, that should be fine. If there is information to store and retrieve, then you can use a database.
You can start simple, just store and retrieve a todo list.
If you want to, you can build around the database to do more:
Have a program that occasionally looks at the list and reminds you of what needs to be done.
Warns you of items with a "drop dead" date that day.
etc.
 
  • #5
shivajikobardan said:
need to make an application that uses database in python, what should I make?
Do you mean just store and retrieve information in your own Python datastructures, or do you mean interface with a real database program like SQL?

https://searchdatamanagement.techtarget.com/definition/SQL
 
  • #6
A cheap kind of database is to encode your keys as directory and filenames. with the data stored in the file.

./addrbook_db/smith/john/info.txt
./addrbook_db/washington/george/info.txt
...

then walk the directory tree to find someone that matches your criteria.
 
  • Like
Likes anorlunda
  • #7
I think that it would be good to learn to use a free relational database utility like MySQL.
 
  • #10
  • Like
Likes FactChecker and jedishrfu
  • #11
anorlunda said:
Before writing anything, I suggest spending a short time learning about databases in general. Here's a good place to start. The last video in the sequence is a project to build your own database. You could do that in Python or Java or any other programming language.

https://www.khanacademy.org/computing/computer-programming/sql#sql-basics
I already know database and sql.
 
  • Like
Likes jedishrfu
  • #12
berkeman said:
Do you mean just store and retrieve information in your own Python datastructures, or do you mean interface with a real database program like SQL?

https://searchdatamanagement.techtarget.com/definition/SQL

shivajikobardan said:
I already know database and sql.
It's probably best to use a python module that uses the python database api specification 2.0. (most of them) https://www.python.org/dev/peps/pep-0249/
They basically all work the same, except for the connect() method.
You need to make your own SQL queries, but it is easy to move your python data into parameters of the query, or to read the results into python structures. You will have to install a database to connect to first.
Eventually you use code like this to read records

Code:
>>> select_movies_query = "SELECT * FROM movies LIMIT 5"
>>> with connection.cursor() as cursor:
...     cursor.execute(select_movies_query)
...     result = cursor.fetchall()
...     for row in result:
...         print(row)
...
(1, 'Forrest Gump', 1994, 'Drama', Decimal('330.2'))
(2, '3 Idiots', 2009, 'Drama', Decimal('2.4'))
(3, 'Eternal Sunshine of the Spotless Mind', 2004, 'Drama', Decimal('34.5'))
(4, 'Good Will Hunting', 1997, 'Drama', Decimal('138.1'))
(5, 'Skyfall', 2012, 'Action', Decimal('304.6'))

Tutorials for mysql and postgresql.
https://realpython.com/python-mysql/
https://pynative.com/python-postgresql-tutorial/

Django, will allow you to define python classes to make a database model. (your classes will be subclassed of the django model class). Django will write the sql queries for you to create, update and query the tables in an underlying database, and you only have to interact with python objects. Its main strength is using the data on a website you create with it. It's probably best to try the python db-api first.
 
  • #13
I hope you understand that a private scheme to saving and retrieve your own data is not the same as using an existing database.

With an existing database, there are other interfaces for people to interact with the data in addition to your program.
 
  • #14
I have an upcoming assignment that I need to make an application that uses database, that has frontend. What can I make? Things I am thinking about-:

1) User authentication

2) To do website.

What else are possible, please open my mind?
I am creating it in django.
 
  • #15
You are repeating yourself. Do some preparatory work first.

##\ ##
 
  • Like
Likes shivajikobardan
  • #16
BvU said:
You are repeating yourself. Do some preparatory work first.

##\ ##
What preparatory work should I do?
 
  • #17
I like your sense of humour :smile: !
What about reading post #12 by @willem2 ?
Or doing some internet research on 'how to get started with ...' ?

##\ ##
 
  • #18
You can consider TinyDB. Look through the documentation. It stores data in the JSON format, which may allow you to extend and scale your project in the future.
 
  • Like
Likes jedishrfu

1. How do I connect to a database in Python?

To connect to a database in Python, you will need to import the appropriate database module, such as MySQLdb for MySQL or psycopg2 for PostgreSQL. Then, you will need to establish a connection using the database's connection method and provide the necessary credentials.

2. How do I execute SQL queries in Python?

To execute SQL queries in Python, you will need to create a cursor object from your established database connection. Then, you can use the cursor's execute() method and pass in your SQL query as a string. Finally, you can use the cursor's fetchall() or fetchone() method to retrieve the results of your query.

3. How do I handle errors when working with a database in Python?

To handle errors when working with a database in Python, you can use a try-except block to catch any exceptions that may occur. This will allow you to handle the errors in a specific way, such as displaying an error message to the user or rolling back any changes made to the database.

4. Can I use an ORM with a database in Python?

Yes, you can use an Object-Relational Mapper (ORM) with a database in Python. Some popular options include SQLAlchemy, Django's built-in ORM, and Peewee. These ORMs allow you to interact with the database using objects and classes instead of writing raw SQL queries.

5. How do I ensure the security of my database when using it in a Python application?

To ensure the security of your database when using it in a Python application, you should use prepared statements or parameterized queries to prevent SQL injection attacks. You should also properly secure your database credentials and limit access to the database to only authorized users.

Similar threads

  • Programming and Computer Science
Replies
1
Views
767
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
7
Views
488
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
1
Views
732
Replies
6
Views
658
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
28
Views
734
Replies
7
Views
243
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top