How to vizualize the data from postgresql?

I would like to create a web page using django and postgresql. I can’t vizualize data using postgresql. I was trying with mysql and everything is OK but with postgresql it doesn’t work. Here is my code from github:

I’m trying to migrate from mysql to postgresql because I would like to upload my site in circumeo.

Could you please help?

Your template and your view don’t match each other.

Your template is trying to render something called public.score1, but that is not what you’re passing to the rendering engine in the view (patients).

Side note: In the future, please do not post just a link to a repo without providing some details about what files and functions you think are involved in the issue.

Thank you for your reply! I revised views.py replacing patients with score1 but still the table from my database is not visible on my web page. There are no errors but the table with the information is not visible! I think that there is a problem with views.py, models.py, settings.py and the database ‘prida’ and the table ‘score’ from postgresql.

Your template still doesn’t match what you’re passing in the context.

You’re now passing the variable score1, but trying to iterate over an object named public.score1.

Thank you for your reply!
Now everything is working after revising models.py and views.py. I can visualize the data from my database using postgresql. Check please:

Now I would like to post my web site into Circumeo but there is something wrong in my database configuration. Could you please help? I have imported my project from github but there is something wrong and the page could not be load. Here is my link:

https://hr4-meticulous-pasteur.circumeo-apps.net/

What do you think that error is telling you?

I was trying to load my web page through circumeo and postresql but without success. I think that I have problems with settings.py and the database settings. I don’t know that is so important to create the file requirements.txt and the folder staticfiles. Definitely something is wrong with my database in circumeo.

Ok, but I was being very specific with my question.

What precisely is that error message telling you? (I’m not asking you to identify the cause of the problem, only to identify the specific symptom that needs to be addressed.)

Here is my project from github:

The error is:

502 Bad Gateway

Ok, that’s a different error message than yesterday when I went to the location linked at How to vizualize the data from postgresql? - #5 by tihobg.

In this situation, you’re going to need to look at your server logs, both for nginx and your application. (Depending upon how you’re running your project, you may also need to check syslog as well.)

Something is wrong with my database and can’t revise the project using circumeo. Is it any different option how to host my project for free like circumeo and pythonanywhere. I’m using python version 3.12.0, django 5.1.2.

This is my database setting in settings.py:

DATABASES = {
“default”: {
“ENGINE”: “django.db.backends.postgresql”,
“NAME”: os.environ[“POSTGRES_DB”],
“USER”: os.environ[“POSTGRES_USER”],
“PASSWORD”: os.environ[“POSTGRES_PASSWORD”],
“HOST”: os.environ[“POSTGRES_HOST”],
“PORT”: os.environ[“POSTGRES_PORT”],
}
}

I receive the error:

ProgrammingError at /

relation “score1” does not exist LINE 1: …patient_id", “score1”.“name”, “score1”.“value” FROM “score1”

After revising the code in index.html and deleting these lines:

{% for patient in score1 %}
<tr>
<td>{{ patient.name }}</td>
<td> got a {{ patient.value }}</td>
</tr>
{% endfor %}

everthing is OK but I can’t visualize the data from the database.

How to set my database in circumeo (name, host, port, user)?

It’s not telling you that you can’t connect to the database, there’s no error giving you any indication that it’s a connectivity or settings problem.

What this message is telling you is that the table you’re trying to access doesn’t exist.

After changing the table score1 with public.score1, there is no errors but the data could not be visualized.

What specifically did you do here?

Have you verified that the table exists in the database, and that there’s data in that table?

Here is a screenshot of my table:

And this is the same database with the same credentials that you have configured in your application?

This is my database that is working when I am using localhost!

This is my database and table but where I can write my password, port number and user name?

I’m not following what I think you might be trying to describe here.

You have been showing a database that appears to be on your PC.

You’re now going to deploy this code to a server.

The server isn’t going to have access to your database on your PC - it’s going to need to access a different database.

It’s up to you to ensure that:

  • That database exists
  • The user exists and has the correct permissions on that database
  • The Django project is correctly configured to access that database
  • The database has the right tables
  • The tables contains the right data

The symptoms you are showing indicate to me that everything was correct except for the last two steps.

You need to verify if that is true.

Does the database that your project is using have the correct tables and data?

1 Like

Where I can see my right name of the database that I’m using in Circumeo? Really I am trying to connect a database that is on my PC!