I am developing a new application on Django (DRF + Angular). The current LTS version of Django 2.2. The required data is stored in the PostgreSQL 8.4 database. But Django 2.2 supports PostgreSQL 9.4 and higher. Update PostgreSQL is not possible. What to do in this situation? What are the options?
I think what you can do is to:
dump your information in the database to a separate file
uninstall and upgrade your postgres server
load the earlier dumped data back to your new database
Since I don't know your operating system so I can't give you clear command-line instructions, but do check out the docs. By the way, since you're changing, why not switch to Django 3 directly? Otherwise you might've to repeat this process again.
Hope this helps
Luckily you are on the minimum supported version for this, so you can use pg_upgrade to update your Postgres install (docs)
This way you don't need to dump/restore your database. The process is a little long-winded so I'll refrain from copying it all here in case this becomes out of date.
Related
How can I use Tarantool in conjunction with Django and MySQL for caching (instead of i.e. Redis) and/or in the sense that all read transaction go to Tarantool (after insured MySQL replication) and all writes go into MySQL (preferred option) Would anyone have a sample?
Well. Tarantool does not have a Django plugin. That means you have to introduce it first. By the way, tarantool has python 2.71 and python 3.x1 libraries, so it may be useful for integration.
How it could be implemented? You have to use taranool's python library and also MySQL's python library for creating some Django / Python plugin.
Also. About MySQL replication. Tarantool has this feature, you can get codes from GH repo[2].
I'm not sure that Django's sample could be found.
Afterword. It's the pretty big task :)
1 https://github.com/tarantool/tarantool-python
[2] https://github.com/tarantool/mysql-tarantool-replication
UPD: February 2021:
The Django-Tarantool Database Backend was introduced as django-tarantool PyPi package and can be used for Django 1.10-3.1 versions.
pip install django-tarantool
Feel free to contribute to the package https://github.com/artembo/django-tarantool
im working on python application that requiring database connections..I had developed my application with sqlite3 but it start showing the error(the database is locked).. so I decided to use MySQL database instead.. and it is pretty good with no error..
the only one problem is that I need to ask every user using my application to install MySQL server on his pc (appserv for example) ..
so can I make mysql to be like sqlite3 apart of python lib. so I can produce a python script can be converted into exe file by the tool pyInstaller.exe and no need to install mysql server by users???
update:
after reviewing the code I found opened connection not closed correctly and work fine with sqllite3 ..thank you every body
It depends (more "depends" in the answer).
If you need to share the data between the users of your application - you need a mysql database server somewhere setup, your application would need to have an access to it. And, the performance can really depend on the network - depends on how heavily would the application use the database. The application itself would only need to know how to "speak" with the database server - python mysql driver, like MySQLdb or pymysql.
If you don't need to share the data between users - then sqlite may be an option. Or may be not - depends on what do you want to store there, what for and what do you need to do with the data.
So, more questions than answers, probably it was more suitable for a comment. At least, think about what I've said.
Also see:
https://stackoverflow.com/questions/1009438/which-database-should-i-use-for-my-desktop-application
Python Desktop Application Database
Python Framework for Desktop Database Application
Hope that helps.
If your application is a stand-alone system such that each user maintains their own private database then you have no alternative to install MySQL on each system that is running the application. You cannot bundle MySQL into your application such that it does not require a separate installation.
There is an embedded version of MySQL that you can build into your application (thanks, Carsten, in the comments, for pointing this out). More information is here: http://mysql-python.blogspot.com/. It may take some effort to get this working (on Windows you apparently need to build it from source code) and will take some more work to get it packaged up when you generate your executable, but this might be a MySQL solution for you.
I've just finished updating a web application using SQLite which had begun reporting Database is locked errors as the usage scaled up. By rewriting the database code with care I was able to produce a system that can handle moderate to heavy usage (in the context of a 15 person company) reliably still using SQLite -- you have to be careful to keep your connections around for the minimum time necessary and always call .close() on them. If your application is really single-user you should have no problem supporting it using SQLite -- and that's doubly true if it's single-threaded.
How to install two different versions of django. I went through many answer but none of them satisfying my need.
1.I want two install 1.5 or 1.6 without replacing 1.4
2.My application is currently live which was developed using 1.4.
3.But I want to use some python-django libraries to get new features in my application.
4.That library is compatible with django 1.5+.
5.I dont want to use virtual environment.
6.And I want to install in same directory/dist-packeges.
Is there any way two do so,,,,,,?
You can't have two versions in the same project. That's impossible: they would simply conflict - for example, what would happen when you did from django import template? How would the system know which version to use?
The only thing you could possibly do is have two separate projects, with their own versions of Django (and yes, using virtualenvs), each serving a part of the site.
Otherwise you will simply need to upgrade your existing project to Django 1.5+. It's not hard, Django is very good with backwards compatibility.
You have two options.
Django code is open to you So I will suggest to customize your current Django code with any library you want.
Or Create new app as utils and override current django feature into this new app and use this app as a django plugin.
I have a standard django setup using postgres, but I also want to access data from a mssql database. I have installed pyodbc and was in the process of installing django-pyodbc but the instructions tell me how to make the mssql the default database which is not what I want.
I was hoping somebody could point me in the right direction. It doesnt bother me if the method bypasses django and just uses Python to retrieve the data
Cheers,
JJ
If you're using Django 1.2 or later, you can use Django's built-in multi-database support. You can follow the django-pyodbc directions, and give your database a name other than 'default'.
I am working with python's django framework. My models are sqlalchemy and my back-end database is mysql. How will I configure them?
Some links that might help you:
http://lethain.com/entry/2008/jul/23/replacing-django-s-orm-with-sqlalchemy/
http://code.google.com/p/django-sqlalchemy/
http://adam.gomaa.us/blog/2007/aug/26/the-django-orm-problem/
http://gitorious.org/django-sqlalchemy
See Django database installation,
If you’re using MySQL, you’ll need MySQLdb, version 1.2.1p2 or higher. You will also want to read the database-specific notes for the MySQL backend.
And the MySQL notes,
Django expects the database to support transactions, referential integrity, and Unicode (UTF-8 encoding). Fortunately, MySQL has all these features as available as far back as 3.23. While it may be possible to use 3.23 or 4.0, you'll probably have less trouble if you use 4.1 or 5.0.