How to display current configuration in Doctrine 2. I found the answer for Doctrine 1 here: Find current Doctrine database connection settings in symfony, but nothing for Doctrine 2.
You have all you need in Doctrine\DBAL\Connection instance:
var_dump($entityManager->getConnection());
Related
I'm trying to create a project using django with a populated database, my problem is when I try to create a new object I get this error duplicate key value violates unique constraint, because the database is already populated, what can I do to change it to make Postgres manage it or django to get the right sequence?
thanks in advance
It's not entirely clear what you're asking. Are you getting the errors because Django tries to create tables that already exist in your database? If so, you can add managed = False to your model's Meta class and Django will not touch the database for this model. It will then be your own responsibility to keep your tables up to date with your Django models.
See the documentation here: https://docs.djangoproject.com/en/2.0/ref/models/options/#managed .
I found that Django has support for Postgres' range fields and also found that in Postgres, we can have non-overlapping constraint (exclusion constraint) as described here at section 8.17.10.
Can anyone tell me how can I apply this constraint in Django in Field iteself not in migration file.
I am using django 1.8 and postgres 9.4
Your help will be highly appreciated.
I am not sure you can create a constraint without migration file ( going to the database by consequence ) but as an option, you can use Django fields validations that will raise exceptions in case you validations don't pass
https://docs.djangoproject.com/en/2.0/ref/validators/
I have a relational database on MSSQL, I've created this one on a different schema (titan) than DBO. When I try to retrieve the models from my database, the composer of strongloop arc only shows those tables that are currently saved on DBO schema but not my tables saved in my custom schema.
Any help might be useful. Thanks in advance.
For relational database discovery, LoopBack API allows you to supply schema and table. But the schema is not exposed by StrongLoop Arc. As a result, only default schema names are used by Arc. Please note dbo is the default schema name for mssql.
I suggest you open a feature request on github for StrongLoop Arc.
I'm using ZF2 and Doctrine2
Please refer the screen shot , this error will show how to fix it ?
For the future, Nimesha, I'd like to ask of you to not post Screenshots where it's not required. The error messages are clearly outlined by the Error Handler of Zend Framework 2 and Copy&Pasting the message into google - in this case at least - will easily get you to the results.
What you've done wrong is, you've forgotten to specify the namespaces / your doctrine driver. You can find an example configuration in the DoctrineORMModule /docs folder or here on my Github
I asked a recent question about how to load your own parameters in Symfony2, which was answered here How do you load config settings from the database in Symfony2?, but I now need to know how to actually access the database in the import file.
I have tried using:
$container->get('doctrine.orm.entity_manager');
Unfortunately, I then get a "The service definition doctrine.orm.entity_manager does not exist." error.
Can anyone help?
Your code should work.
$this->container->get('doctrine.orm.entity_manager');
But only if Doctrine is enabled.
Have you the Doctrine Bundle in your kernel ? Have you uncommented the doctrine settings in config.yml ?
After asking and looking around for a while the only solution I found to accessing doctrine while Symfony is still configuring its services is using this bundle. Take a look at the readme as it describes a solution to the scenario we are both experiencing.