I have made a PostgreSQL database, and I am trying to connect a python script to it. I need to enter the server name to the script. I have the database name, but I don't know what the server name is. Where do I find that? If it helps I am working through Heroku Postgres.
The official article in the DevCenter states:
To use PostgreSQL as your database in Python applications you will need to use the psycopg2 [...] to connect to DATABASE_URL in your code.
So I guess there is no server name needed with that package.
Related
first of all, sorry for this dumb question.
secondly, this is the scenario, i made executable file from python, my app need to connect to mysql database, in my app script is using mysql.connector.
thirdly, what i want to know, is my app can run and connect to mysql database in another pc that does not have mysql driver installed? *because of poor resource, right now i can't just try and find out my self.
if it can't, can i using sqlite and then all the pc client data saved in 1 file database that place in shared folder, so 'admin' can read it anytime?
thank you so much
I have a remote database server in godaddy. I want to use that for database connectivity for my Django Project. Because, I want to access the data stored in pythonanywhere database and it is said that, it is accessible unless you have the SSH keys which is provided only if you have paid account.
Is there a way to configure the settings.py database values to access it remotely from a java program?
Thank you!
First of all, are you trying to access GoDaddy database from within PythonAnywhere? (if so, you will have to deal with GoDaddy security restrictions/rules on their database) Or are you trying to access a PythonAnywhere database from GoDaddy/somewhere else? (In which case, you would have to deal with PythonAnywhere security rules- which means that you will have to use ssh tunnelling for this use case)
In any case, if the database you need to access is only available over ssh tunnelling, check out the sshtunnel python package.
I've followed the Djangogirls tutorial and usually the tutorial calls for you to create a database on pythonanywhere. This usually works without a hitch when using sqlite3 however this time I'm using postgresql and I got the below error when I ran the migrate command in the console:
conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql
What does this mean exactly?
using python 3.5.1
django 1.9.8
postgresql 9.4
Thanks
Ok after reading around some more, this is my problem in a nutshell.
I have postgresql running locally. I then deployed the wbapp onto pythonanywhere. Whilst there I tried to create the database by running migrate which resulted in the above error.
Since then i realised that I had to setup postgresql to run on pythonanywhere. I followed the instructions and did that, but what I don't understand is do I now have to create the database from scratch? And if that is the case what happens to all my tables etc. from my local database?
To clarify, you should not be trying to connect to your local postgres. Instead, you should setup postgres on pythonanywhere, and make sure that your django settings.py is pointing the database address and port to the pythonanywhere database. Which is not local to the console/webapp server that you are running your code on. Instead, go to the pythonanywhere database tab and look at the address/port that is given to you.
According to their help page you need to upgrade to a paid account to be able to use postgres.
I need help switching my database engine from sqlite to mysql. manage.py datadump is returning the same error that pops up when I try to do anything else with manage.py : ImproperlyConfigured: Error loading MySQL module, No module named MySQLdb.
This django project is a team project. I pulled new changes from bitbucket and our backend has a new configuration. This new configuration needs mysql (and not sqlite) to work. Our lead dev is sleeping right now. I need help so I can get started working again.
Edit: How will I get the data in the sqlite database file into the new MySQL Database?
According to the Database setup paragraph in Django docs:
By default, the configuration uses SQLite.
If you wish to use another database, install the appropriate database
bindings...
And Get your database running page says:
If you’re using MySQL, you’ll need the MySQL-python package, version
1.2.1p2 or higher.
To use MySQL backend you need a tool that would help Django talk to the database, an adapter.
In other words, MySQL-python (aka MySQLdb) package needs to be installed.
Try the followings steps:
1. Change DATABASES in settings.py to MYSQL engine
2. Run $ ./manage.py syncdb
I have a written a very small web-based survey using cgi with python(This is my first web app. ).The questions are extracted from a MySQL database table and the results are supposed to be saved in the same database. I have created the database along with its table locally. My app works fine on my local computer(localhost). To create db,table and other transaction with the MySQL i had to do import MySQLdb in my code.
Now I want to upload everything on my personal hosting. As far as I know my hosting supports Python,CGI and has MySQL database. And I know that I have to change some parameters in the connection string in my code, so I can connect to the database, but I have two problems:
I remember that I installed MySQLdb as an extra to my Python, and in my code i am using it, how would I know that my hosting's python interpretor has this installed, or do I even need it, do I have to use another library?
How do I upload my database onto my hosting?
Thanks
If you have shell access, you can fire up the python interpreter by running python and type import MySQLdb at the >>> prompt. If you get no errors in return, then its installed.
Likewise, if you have shell access, this page will help you with importing and exporting using the mysql command. I found it by googleing "import export mysql".
You can write a simple script like
import MySQLdb and catch any errors
to see if the required package is
installed. If this fails you can ask
the hosting provider to install your
package, typically via a ticket
The hosting providers typically also provide URL's to connect to the MySQL tables they provision for you, and some tools like phpmyadmin to load database dumps into the hosted MySQL instance
To check if MySQLdb library is installed on your hosting, simply open a python shell and type: import MySQLdb. If everthing goes ok, you're readt to go. If you get: ImportError: No module named MySQLdb, that means the the library is not installed and you nedd to install it.
You need that library or some library that provides similar support, because Python does not support native access to MySQL databases.
To transfer you database to your hosting check mysqldump.