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.
Related
Its's nice to see mongodb is connected with django but doesn't support completely. I explain why so because when you install any third party packages to your project it could written for Django models not Djongo which will fall you in Database error while migrating you apps.
djongo.database.DatabaseError
Do we have any solution for this case?
Well, in the general case, the solutions you have are, in increasing order of difficulty:
Get rid of Djongo. Use Django with an SQL database, as that's what it's designed for. You can still use MongoDB for whatever data you might have in there, but the main Django database is better off being SQL.
Don't use packages that don't work with Djongo.
Fix the packages that don't work with Djongo to work with it.
I would recommend going for (1)...
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.
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
I have been searching for libraries that can handle database migration for tornado framework. How is the database migration handled in Tornado framework ?
I was working on Yii Framework before and it has a very convenient CLI tool to handle Database migration.
I am looking for something like that.
I highly recommend Alembic. It was originally written to support SQLAlchemy, but you don't need to use SQLAlchemy as long you have a relational database it supports. That said, you will need to understand SQLAlchemy Core to work with Alembic, but that is generally a useful skill to have.
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'.