I did not find anything about this in the manual of the Doctrine DBAL or the Search here.
So basically my question is, is there a way to get the Database Server Information using Doctrine DBAL.
PHP has things like "mysqli_get_server_info()" and "PDO::getAttribute(PDO::ATTR_SERVER_VERSION)", so I was looking if the Doctrine DBAL supports something like this as well.
An old question, but I needed an answer as well.
so:
$this->getDoctrine()->getConnection()->getWrappedConnection()->getServerVersion();
Related
In the past, at our project it was decided to use Doctrine with "database first" approach and about 30 tables have already been processed.
We would like switch to the "code first" approach.
Is it possible to somehow build on already finished things or does the whole work have to start from scratch? How to proceed?
Thanks for the advice.
You probably want to generate Doctrine entities based on an existing database schema.
There is some support by Doctrine to do this which cannot handle every case but should get you started.
php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml
For more information see e.g. documentation here
How to configure ZF3 project to be able to use generate-entities command from Doctrine Orm Tools ?
I use Application\Entity namespace for the models, this tool generates entities in Application\Entity directory, not in Application\src\Entity dir.
How to tweak this?
You actually can't tweak this, the doctrine generator is only psr-0 and will not be updated (and will probably be removed in future versions). I do not have sources here, just stuff I reckon reading on the github project.
What you could do though is create a psr-0 loaded module, and change your config to use psr-0 just for your entities, but I would greatly recommend against it. If you want to go down that way, just update your composer autoload section to add your psr-0.
Your question is already answered here on stackoverflow. You have 2 options:
Option 1:
How to generate Doctrine entities From Database and Use PSR-4 Autoloading?
Option 2:
Just create the entities manually yourself. ( that’s what I do )
Good luck !
I'm trying to find any information if official django is going to support any noSQL DBMS, especially MongoDB. I found a fork of django 1.3 the django-nonrel (a fork of official django) and some other not very reliable projects (failures occur often, according to comments I found on the web). Is django going to support noSQL officially at all?
Perhaps, there are other ways to achieve your goals, besides going noSQL.
In short, if you just need dynamic fields, you have other options. I have an extensive writeup about them in another answer:
Entity–attribute–value model (Django-eav)
PostgreSQL hstore (Django-hstore)
Dynamic models based on migrations (Django-mutant)
Yes, that's not exactly what you've asked for, but that's all that we've currently got.
As you said, forked code is never the best alternative: changes take longer to get into the fork, it might break things... And even with django-nonrel, is not really Django as you loose things like model inheritance, M2M... basically anything that will need to do a JOIN query behind the scenes.
Is Django going to support NoSQL? As far as I know, there's no plans on the roadmap for doing so in the short run. According to Russell Keith-Magee on his talk on PyCon Russia 2013, "NoSQL" is on the roadmap but in the long term, as well as SQLAlchemy. So if you wanna wait, is going to take a long time, I'm afraid.
Anyway, even if it's not ideal, you still can use Django but use something else as a ORM. Nothing stops you from use vanilla Django and something like MongoDB instead of Django ORM.
I'm build a Django app with Neo4j (along with Postgres), I found this Django integration called neo4django, I was wondering if it's possible to use neo4restclient only, like, what would be the disadvantages of not using Neo4django? Does using neo4-rest-client only, give me more flexibility?
When I was creating my models with Neo4Django, it seemed that there is no difference between modeling a graph db and relational db. Am I missing anything?
Thanks!
You can absolutely go ahead with neo4j-rest-client or py2neo, without using neo4django. In the same way, you can use any other database driver you'd like any time using Django, any REST client, etc.
What'll you lose? The model DSL, the built-in querying (eg, Person.objects.filter(name="Mohamed")), the built-in indexing, and the Lucene, Gremlin and Cypher behind that. Some things will be much easier- like setting an arbitrary property on a node- but you'll need to learn more about how Neo4j works.
You'll also lose some of the shortcuts Django provides that work with neo4django, like get_object_or_404() and some of the class-based views that work with querysets.
What'll you gain? Absolute power over the DB, and an easier time tweaking DB performance. Though neo4django isn't nearly as good a lib as some traditional ORMs in the Python sphere, the trade-off of power vs provided ease is similar.
That said, the two can work together- you can drop down from neo4django to the underlying REST client nodes and relationships anytime. Just use model_instance.node to get the underlying neo4j-rest-client node object from a model, and from neo4django.db import connection to get a wrapped neo4j-rest-client GraphDatabase.
On whether you're missing something: neo4django was written to re-use a powerful developer interface- the Django ORM- so it should feel similar to writing models for Postgres. I've written a bit about that odd feeling in the past. I think part of the problem might be that the lib doesn't highlight the graph terminology new graph-interested devs expect- like traversals and pattern matching- and instead dresses those techniques in Django query clothing.
I'd love your thoughts, or to know anything you'd like the library to do that it isn't doing :) Good luck!
I am in search for a extension that is similar to django_-volution.
The requirement is to alter the database, whitout deleting the wohle data.
I don't know, but for me, this is something so ordinary - doesn't django have a built-in function like that?
django_evolution is still in working progress and has some bugs, so i want something that is stable and maybe has more options. Especially to write own mutations seems a little bit complex for me.
Does anybody know something similar?
Thanks for all answers
You're looking for South. It's currently the de-facto schema and data migration plugin for Django. I believe there have been talks about adding it to the core of Django. It has a bit of a learning curve but you seriously want to take the time and learn it.
You'd like something to perform 'migrations' a la rails, correct? The best known and most stable project is South, as far as I know. It offers "intelligent schema and data migrations for Django projects".
http://south.aeracode.org/
Personally, I just alter my model, and make the changes through the database command line client.