Tornado + SQLAlchemy non-blocking DB calls - sqlalchemy

I'm relatively new to application development but here goes nothing.
I've been working on a project that employs the use of a Tornado server and SQLAlchemy's ORM for database management/access (using postgres in the back end).
At the outset of the project I hadn't considered the possibility that using SQLAlchemy would prevent me from taking advantage of Tornado's async features (since SQLAlchemy's database calls apparently 'block' the thread).
Do you have any suggestions as to how to implement an async-compatible setup with Tornado+SQLA+postgres?

Take a look at aiopg - https://github.com/aio-libs/aiopg
It is a Python 3.4 asyncio adapter for postgres that includes sqlalchemy support. I haven't tried it myself yet, but found it while looking for async libraries for postgres and tornado. I am using Momoko, but it only supplies the raw psycopg2 layer.
Remember that the latest version of Tornado supports asyncio, so asyncio libraries will now work with Tornado.

Related

How to achieve Polyglot with Prisma, MySQL, neo4j and redis?

I am using Prisma + MySQL in Production. Works great! There's a need in near future where we need to use neo4j alongside/completely. Any suggestions on can we achieve this with the existing artifacts, as apparently Prisma doesn't support neo4j. So if we can continue using Prisma or we stop using it and start using neo4j orm.
Prisma doesn't currently support neo4j, though there are plans to add support in the future. Polyglot support is a use case that Prisma is targeting at large. You can follow the development status in the Github issue (👍 to signal your interest).
In the meanwhile, I'd suggest looking at neo4j specific abstractions.
The Node.js ecosystem there is the neo4j driver and an OGM (Object Graph Mapper) called Neode

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.

Hadoop configuration using both MongoDB and MySQL

any one can give sample code from mongodb to rdbs ... I tried already , fetching data from mongodb and output store in mongodb.For that i knew how to do hadoop configuration in java job.
And i want to know three things...
which hadoop version support both mongodb and rdbs?
Is it possible to use multiple collections as input...? If possible, how we can do that?
I tried mongodb query in hadoop,It's working fine.But when i defined sort or limit...It is not working properly..even it's not fetching data from mongodb...
1. which hadoop version support both mongodb and rdbs?
I believe that all versions of Hadoop supporting MongoDB also support RDBMS (the RDBMS implementations predate MongoDB).
For supported versions of Hadoop to use with MongoDB, see: Building the Adapter. Check the version information as some Hadoop versions do not support the Streaming Connector (i.e. if you want to write your jobs in non-JVM languages such as Python).
2. Is it possible to use multiple collections as input...?
If possible, how we can do that?
MongoDB Hadoop Connector v1.0.0 does not support multiple collections as input, but there are a few folks in the community working on this (see: Feature/multiple inputs).
3. I tried mongodb query in hadoop,It's working fine. But when i defined
sort or limit... It is not working properly..even it's not fetching data
from mongodb...
Can you provide an example of how/where you provided these options? Are you referring to the mongo.input.sort and mongo.input.limit properties?
You may want to try enabling the Database Profiler in MongoDB to confirm the queries are being sent:
db.setProfilingLevel(2)

Does Rikulo support mysql database?

I know rukilo is an UI framework for Dart language but I wonder if it supports to use Mysql? And if it is, how to connect mysql with Dart? Thank you
We are developing Rikulo ORM to simplify the database access (but it is not opened yet). The first version will be built on top of WebSQL (SQLite) and IndexedDB. We do have a plan to bridge it to the backend server such as MySQL. Of course, there are some security and performance challenges to deal with.

Is there a good DAL or DAL/ORM for Node.js yet?

I want to experiment a bit with Heroku and Node.js. Heroku uses Postgres by default but I would like the option to use Amazon RDS later on (MySQL). Is there a good database abstraction layer, preferably with a simple object relational mapper around it available at this point? I checked the NPM repository, but couldn't find something that supported both, looked mature and was well documented.
You might be interested in using another hosting provider. For example Duostack is super easy to set up and allows the usage of mysql: http://docs.duostack.com/node/databases#mysql
An ORM for MySQL is e.g. sequelize ( http://sequelizejs.com | https://github.com/sdepold/sequelize ).