I am trying to create a website using Symfony and PostgreSQL. I cant find any documentation that shows how to do this. All the documentation assumes the backend db is mySQL.
Anyone knows how to do this?
If you are using Doctrine, just use a dsn for pgSQL in your databases.yml, like this :
pgsql:dbname=testdb;host=127.0.0.1
It use the PDO syntax. Check the Doctrine documentation and PDO documentation.
Symfony uses 3rd-parties ORMs for DB communication which provide abstraction layer over RDBMS specific architecture. Basically everything you have to do is to change Doctrine's/Propel's driver name, so in /config/databaes.yml set pgsql instead of mysql and you're done.
The full answer (took me about an hour to figure this out) is:
Modify database.yml as described here (see under Propel or Doctrine)
(assuming you're using the Propel ORM like I am) Modify propel.ini as shown below (undocumented AFAIK)
Look for a section in your propel.ini names ;mysql options
comment the mysql options out - otherwise the generated SQL is a mix of postgresql and mysql - which confuses the hell out of psql.
Related
SQLAlchemy 1.4 ORM using an AsyncSession, Postgres backend, Python 3.6
I am trying to create a custom aggregate function using the SQLAlchemy ORM. The SQL query would look something like:
COUNT({group_by_function}),{group_by_function} AS {aggregated_field_name)}
I've been searching for information on this.
I know this can be created internally within the Postgres db first, and then used by SA, but this will be problematic for the way the codebase I'm working with is set up.
I know SQLAlchemy-Utils has functionality for this, but I would prefer not to use an external library.
The most direct post on this topic I can find says "The creation of new aggregate functions is backend-dependant, and must be done directly with the API of the underlining connection." But this is from quite a few years ago and thought there might have been updates since.
Am I missing something in the SA ORM docs that discusses this or is this not supported by SA, full stop?
you can try something this query
query = db.session.query(Model)\
.with_entities(
Model.id,
func.sum(Model.number).label('total_sum')
).group_by(Model.id)
I'm interested to use an AnsiDialect from spring-data-jdbc to connect to my Oracle database using a proprietary driver. However, this dialect is not present in spring-data-jpa (only contains dialects from hibernate)
Is there a way to do this, or do I need to implement my own dialect?
By the looks of it, it seem that the equivalent of AnsiDialect is simply org.hibernate.dialect.Dialect. Don't know why I didn't think about this :)
I am new to Solr with the specific need to crawl existing database table and generate results.
Any online example/tutorial so far only explains about you give documents and it gets indexed, but not any indication of how to do same on database.
Can anyone please explain steps how to achieve this ?
Links like this wiki shows everything with jdbc driver and mysql so I even doubt if Solr supports this with .NET or not. My tech boundries are in C# and Postgresql
You have stumpled over the included support for JDBC already, but you have to use the postgres JDBC driver. The example will be identical with the MySQL one, but you'll have to use the proper URL for postgres instead and reference the JDBC driver (which will depend on which Postgres JDBC driver you use).
jdbc:postgresql://localhost/test
This is a configuration option in Solr, and isn't related to .NET or other external dependencies.
However, the other option is to write the indexing code yourself, and this can often be a good solution as it makes it easier to pre-process the content and apply certain logic before storing content in Solr. For .NET you have Solrnet, a Solr client, that'll make it easy to both query from and submit documents to Solr.
I'm using PostgreSQL as the DB backend for a new Symfony2 + Doctrine2 project. I'd like to take advantage of some of the features of PostGIS, and as such have created a Postgres template for PostGIS.
Right now, I can't see how to tell Doctrine2 to use the PostGIS template instead of the default, looking through the Doctrine2 code hasn't lead me anywhere (to be honest, I'm struggling to figure out how it even works).
Is this even possible? If so, how?
One of your very basic problems is likely to be the fact that when you abstract, you lose low level control. To my knowledge template databases are not likely to be common concepts elsewhere. So you really have to drop to a lower level, connect to the postgres db manually and issue your CREATE DATABASE foo WITH TEMPLATE bar statement yourself.
The comment here says I can use LightSpeed, which I've downloaded and installed. Then I get to this screen:
And I'm not sure what to do. I'm not too familiar with connection strings, first of all. I found this, but... I think "Model assembly" and "Unit of work class" are required. I don't have any DLL's and I'm not working with LightSpeed models, so I'm not sure this is even useful.
The IQ addon Driver works great with my MySQL database. Really easy to set up and use. Are there any drivers that work with PostgreSQL yet? Looks like you can add them by choosing an "*.lpx" file.
I've developed a dynamic LINQPad driver for PostgreSQL databases. Using it you can query the database without the necessity to define your model first (similar to the IQ or the built in LINQ to SQL driver).
You can find it on GitHub:
https://github.com/fknx/linqpad-postgresql-driver
The LightSpeed driver is a static driver, meaning that you must first create a model (and hence a typed DataContext) using the LightSpeed tools.
If you just want to query PostgreSQL in LINQ, you need a dynamic LINQPad driver which no-one has written has yet, AFAIK.