Django ERROR "Intersection is not supported on this database backend" - mysql

I just convert database backend from sqlite to mysql.
But When I test my feature in project is ERROR.
NotSupportedError at /filter/
intersection is not supported on this database backend.
In my view.py have Django ORM Union, Intersection. I think this is the troublemakers. Why It can't use Union, Intersection in MySql Backend.
I try to fix it. But I don't know how. Please Help me T^T

Because the MySQL backend does not support intersection. From Django source:
https://github.com/django/django/blob/a906c9898284a9aecb5f48bdc534e9c1273864a6/django/db/backends/mysql/features.py
supports_select_intersection = False
You can switch to another database backend which supports intersection, or rewrite your query in a way that doesn't require intersections.

Related

Can I use GraphQL for mongoDB or mySQL?

I have started learning GraphQL and found that GraphQL is an awesome query language.
However I wonder if I can use GraphQL for existing databases such as mongoDB or mySQL.
Also please explain about prisma.
Is prisma a cloud database or something?
Edit:
TL;DR:
GraphQL can be used with any database as long as the data satisfies the type-strict qualification. Prisma is a node.js/typescript ORM library and works great with GraphQL.
Looking back to this a bit old question, I noticed that the question was so dumb and a bit too wide. So I've decided to add some more thoughts as I'm now quite familiar with GraphQL and Prisma. Hope this could be a help for new developers who are starting to learn GraphQL and Prisma.
GraphQL is a query language that we can use to interact with the API.
Like the REST API, GraphQL is another type of API format where we can use Queries to get data and Mutations to update data.
As the REST API doesn't depend on the database type, GraphQL can also be used with any database as long as the data can be formatted into type-strict models.
On the backend side tho, you need to implement the GraphQL interface that reads data from the database and sends as the Query response, and updates the database with the data from the Mutation.
Prisma on the other hand is a node.js/typescript ORM library - similar to mongoose or sequelize. The benefits of using Prisma is that it auto-generates the TS models and makes it much easier to interact with the database in typescript.
As GraphQL and Prisma are both strict in type usages, they match quite well. Also, Prisma provides an exclusive interface for GraphQL implementation, so you can easily write GraphQL interface with Prisma.
Please check out here for more information on the combination of GraphQL and Prisma: https://www.prisma.io/graphql
It was a long edit, but hope this helps.
As it was mentioned on previous post - yes, you can.
An example, if you backend application wrote on .NET stack - you may use, guess two, main libs that really tested and guys use it in real projects (google GraphQL.Net and second lib should be spelled almost the same)
But, both of these libs give you only processing of graphql queries and describe schemes ("accounts {id name}" means you should define resolver which returns data from db or another data source)
Most of guys use EF (EntityFramework) as a data-adapter between GraphQL and db. But, from my point of view it's useless, especially, if we are talking about get data from db and that may be thousands requests.
We implemented component that based on light-weight DB lib (to almost all popular dbs like MSSQL, Postgresql, MySQL or Elasticsearch), gives ability to configure GraphQL scheme very easy and provide main features like sort, pagination and complex filter.
Yes, you can use it with existing DB.
Prisma is an ORM layer build using GraphQL server, it abstracts away the database and let you interact with the database using GraphQL query. It currently supports MySQL, MongoDB, AWS RDS & PostgreSQL. It's not a database, but you can host it on the cloud.
Typically, you need another GraphQL server that inside it resolvers will call Prisma's GraphQL server. This GraphQL server is the one that is called by the client.

MySQL Views Support in Sequelize ORM

I woululd like to use sequelize as my ORM in a web app I am building. The app will be based on NodeJS - Express for constructing and MySQL as its relational database. What I haven't found anywhere on documentaino or on the net, is how to declare in sequelize models the "Views" that exist in my MySQL Database....
Is the only way to manually construct the query SQL? Thanks
You can use Node ORM2, which has support for MySQL views as well.
Try at
https://github.com/dresende/node-orm2

mysql framework for node.js

Is there any mysql framework for node.js?
I found only https://github.com/felixge/node-mysql but this only allows executing "raw" mysql statements. I am looking for some tool which will provide easier way of manipulating mysql database and data.
Especially I need pagination and joining mechanisms...
I am not looking for a full framework because I am using restify to build RESTapi - just need a module to retrieve/save data to mysql db. So I need only "model" part of MVC ;).
It sounds like you may be looking for an ORM. If that's the case, you can take a look at Sequelize. It will let you define your objects, and then simply 'save' and 'fetch' them, without really having to worry about how its doing it.
You can look at db-mysql module. This module provides api for creating queries. Here is module GitHub page.

Using existing mysql schema in nodejs

I tried using sequelize and node-orm as well - but is there a way to reuse existing mysql schema? I Have a db schema defined with tables in mysql and wanted to use this with my node.js app (using express). So, I don't have to write all the define methods of defining tables again.
Any help appreciated...
I went through bunch of stackoverflow questions already such as: Which ORM should I use for Node.js and MySQL?
Thanks,
JP
Checkout bookshelf.js, it doesn't require that you define the schema in the model layer.

Node.js doesn't have a good ORM for managing MySQL schema/migrations...so can I use SQLAlchemy to manage it?

I need to use Node.js, but it doesn't have a good ORM for MySQL. So I'm planning on using SQLAlchemy to define my schema. And then use node-mysql to do low-level queries (of course, I wouldn't be able to use SQLAlchemy's query language coz it's in python.)
What do you guys think?
sequelize seems to be the best one...but it doesn't seem that many people are using it. Also, what about migrations? How would I handle that?
node-orm doesn't seem very active either.
Thoughts on this?
Sequelize is pretty good ORM for MySQL and has excellent documentation. You can use node-migrate for migrations.
We are using Sequelize.js in our Node project and I guess it kind of does the job done but there are gotchas. One example is that the MySQL Sequelize query engine does case sensitive string matching on the SQL string that you feed it (this.sql.indexOf('SELECT') == 0). This means it can fail if your SQL happens to be lowercase. SQL keywords are usually case insensitive (although upper case by convention) so the Sequelize implementation seems like a hack.
There is migration support in Sequelize as of version 1.3.0 but I haven't used it and I'm considering rolling my own instead.
I come from a background of having used the Ruby ActiveRecord ORM and in light of this and the gotcha mentioned above I'm hesitant to recommend Sequelize. Unfortunately, I don't know what better alternatives are out there.
UPDATE1: there are other ORMs suggested under "Which ORM should I use for Node.js and MySQL?".
UPDATE2: I've released my Sequelize.js migration code on Github
You can use light-orm and mysql:
https://npmjs.org/package/light-orm - ORM wrapper
https://npmjs.org/package/mysql - Driver
Bookshelf.js is also pretty good, but, in some aspects, not flexible. For example, you can not execute SQL request and convert result to models. So, use light-orm.