How to access sqlite3 on pythonanywhere.com? - django

I've followed the DjangoGirls tutorial and i created a blog on my local setup. I used SQLite3 database, since this was suggested by Django tutorial, as being the default one. My local SQLite3 database has several posts. I pushed my code on pythonanywhere.com. Now, my local DB is not synchronized with the online DB, i mean my posts are not seen on the internet. I managed to create a blog_data.dmp DB dump on pythonanywhere.com, but can not access it on pythonanywhere. Can someone help me please with this?
enter image description here
Thank you very much!

I can think of 2 reasons that your database is not available on PythonAnywhere:
You didn't actually upload the database file.
You're referring to the database file using a relative path. That means that your code is relying on the working directory which may be different on PythonAnywhere. Use an absolute path to refer to your database.

Related

Have I to delete SQLite database from the directory after migrating to PostgreSQL on Django 2.2?

I am new to Django 2.2 and I found that SQLite is default database engine here. But I want to use the PostgreSQL instead of SQLite.
I have created a new project and migrate the (ex: Post) model after creating and adding the app to the settings.py and admin.py file. And after that, I decided to use the postgreSQL, and I did it too by migrating to postgreSQL. Before migrating I created a postgres database and add all the necessary details to the settings.py file's DATABASE settings according to instruction of Django. It's working fine. I haven't got any problem yet. Though I see still the sqlite database file still in the project directory. It looks bit odd though. I'm new to Django. Can you please tell me should I keep that file there or delete sqlitedb file? And is there any security issue with sqlitedb file if I keep there? I love to want a neat and clean project settings. Thanks in advance my dear friends!
It's totally up to you. If you want to keep then keep it. And if you want to delete that file delete it. There is no security reason or any problem will occur. Just delete it if you don't need it.
When to Use SQLite?
All applications that require portability and don’t require expansion.
In cases where applications need to read or write files to disk directly.
When to Use MySQL?
Where high-security features are required for data access.
For websites that work on MySQL despite some constraints.It's a
scalable tool that is easy to manage.

how to import data to my database using my same database on my pc?

I have a website that written by django and also same django code on my pc. you call the website www.mywebsite.com and my localhost on my pc is www.127.0.0.1.com, I use the same database model object for two database but I don't want to change my website's database by www.mywebsite.com/admin. I prefer change database on my pc that is www.127.0.0.1.com/admin and update my website by output of that. I should note that I use postgresql with same table and field for both. Please help me. thanks.

postgres connection details in django and chef

I have a django application that uses a postgres DB.
I have a chef recipe that sets up the postgres DB, including setting up a postgres username/password for the django app to use.
This username/password is then used by the DATABASES settings.py value.
At the moment I have to have the postgres details in both attributes.rb and in settings.py.
How can I have them in just one place?
Options I have currently considered:
Having settings.py (or part of it) generated by a chef template. That way the details only need to be in the chef recipe.
The downside of this is that the django app is incomplete unless it is deployed via chef. (This might not be that much of an issue, as even local dev is done with vagrant+chef).
Having a known file on the filesystem that settings.py checks and loads some values from. This file is generated by chef.
This is only a little bit better than the first solution. Also it requires some boilerplate code in settings.py to load and parse the file.
Have the details in settings.py and let chef extract them (somehow).
This approach is problematic because it muddles with the ordering in the chef recipe (I have to check out my django app, extract the value, use the values to set up postgres, and then start django).
That itself might not be too bad, but the real issue comes when/if I want to move to a system where passwords aren't in source-controlled files but in something like chef's data-bags.
I've googled quite a bit, but other than various discussions on the layout of settings.py and general talk about how to use django and chef, I can't find a nice solution.
Surely someone else has deployed a django app with postgres using chef and come across this before?
You should use a data bag. And as you store a password there, it should be encrypted data bag. Then you can read data from it in both recipes (postgres and python).
And storing your passwords in attributes also is not a good idea - because they are too exposed.

Transfer pimcore site to another server

Hy,
I am really new to Pimcore (I'm a joomla guy) and my friend asked me if I could help him transfer a page based on Pimcore to another server. I made a sql dump and copied all the files from the server to my hd and after that on the new server, imported the sql database, changed the username in the db and copied all the files back on the server. Also I made the correct changes for the db in the system.xml file in the config folder. But now all I get is a blank screen but the backend works partially (I can't see the files and the page). I would really appreciate some help!
Thanks in advance
Several things could go wrong, but start with checking:
MySQL user has access to the imported views. This is quite a common issue when importing views between servers,
Apache Linux user has read/write access to the whole website/var folder, access to /var/config is not enough. Pimcore writes cache files to website/var/cache for example.
You are missing mod_rewrite in apache, or your vhost does not allow override.

My Apache (mod_wsgi) Django app only lists the files instead of the actually running website/application

My Apache (mod_wsgi) Django app only lists the files of my website/project instead of the actual running website/application. My guess is that it's mod_wsgi that is the culprit but I'm not really sure. What are some of the causes of this?
Don't put your Django site code in a directory Apache can serve up. Right now if I knew the actual site host name, I could get down your Django settings file and get access to your database password information.
Anyway, ensure you have gone and set up a basic WSGI hello world program before you attempt to get Django working under mod_wsgi. In doing this, ensure you use the official mod_wsgi documentation and not some arbitrary persons blog post. As such, go read:
http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
Also go watch the video presentation at:
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations
as it steps you through basic configuration as well as what to do for Django. It covers all the basic things that people do wrong.
If you still can't get it to work, then heed the comments in:
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Asking_Your_Questions
about useful information you should supply to any forum to help people solve your problem.