TorMySQL | The highest performance asynchronous MySQL driver | Reactive Programming library
kandi X-RAY | TorMySQL Summary
kandi X-RAY | TorMySQL Summary
Presents a Future-based API and greenlet for non-blocking access to MySQL. Support both tornado and asyncio.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Connect to the server
- Return a new cursor object
- Initialize connection
- Wrapper for async_call
- Read num_bytes
- Close the socket
- Read from the stream
- Read number of bytes from the stream
- Check if all idle connections have expired
- Close a connection
- Gets the last query
- Start an SSLIOStream
- Called when the connection is closed
- Close the connection
- Configure asyncio
- Use tornado tornado IOLoop
- Callback called when a connection is connected
- Continue the next wait
- Handle events
- Set the state of the stream
- Close the stream
- Write data to the MySQL server
- Read from the server
- Create a tornado tornado tornado IOLoop
- Send data to the server
- Close the cursor
TorMySQL Key Features
TorMySQL Examples and Code Snippets
self.pool = tormysql.ConnectionPool(
max_connections=256,
wait_connection_timeout=5,
idle_seconds=7200,
host=,
db=,
user=,
passwd=,
cursorclass=tormysql.cursor.DictCursor,
Community Discussions
Trending Discussions on TorMySQL
QUESTION
I have an old, large project based in Python 2.7 with Tornado framework. To work with MySQL, it initially used Tornado-MySQL with raw SQL queries, and it worked well, but now it must use MySQL 8, and that library is obsolete, unmaintained.
So, now I set TorMySQL library – it connects well to MySQL Server 8, but I don't fully understand how to use it, and this leads so bugs.
In one project's file I wrote this code to access databases:
...ANSWER
Answered 2018-Nov-24 at 01:46You probably have to conn.commit() even after a SELECT query - otherwise a run of SELECT queries are done within the same transaction as the first.
I think most users are accustomed to "autocommit" by default, but that does not seem to be the default mode for TorMySQL
(I was confused the same as you were, for the first couple days of using TorMySQL :)
QUESTION
I have a tornado server which will create web-socket connection with clients. Whenever a client requests for some data I need to get it from either Redis or MySQL-DB. In addition to this I need to listen to broadcast from the tornado server, receive the network packets and send them to the clients if they are subscribed for the data. This sending of broadcast packets to client depends on the token which will be there in the packet. If clients are subscribed to the token we should send the packet to him.
Request rate:
- 5000 active web socket connections(Which can increase)
- 1-DB request per socket-connection per second so total 5000 DB-requests/second
- 1-Redis request per socket-connection per second so total 5000 Redis-requests/second.
- In broadcast I should listen to 1000 packets/second and check if any of the users are subscribed for the token.
I know redis is single threaded and work asynchronously(correct me if I am wrong). For MySQL-DB asynchronous driver which I am using is `tormysql`(Most of my calls to DB are select queries and no complex DB operations.).
My Question:
- Will the call to MySQL-DB is blocking? If they are blocking call can I run different thread/process just for DB queries?
- Is there a chance that tornado drop packets on the broadcast?
- I can have a load-balancer in front of my resources and server them but is it possible that I can use a single CPU with 2-cores 8-GB RAM?
Update 1:
I have written a code for MySQL:
Server.py
ANSWER
Answered 2018-Apr-27 at 08:26
- Will the call to MySQL-DB is blocking? If they are blocking call can I run different thread/process just for DB queries?
As you mentioned you're using tormysql
as the driver, so no, the calls won't block since tormysql
is asynchronous.
- Is there a chance that tornado drop packets on the broadcast?
I don't quite understand what you mean by that. But since the websocket protocol is built on TCP, so delivery of all the packets is guaranteed. TCP takes care of that.
- I can have a load-balancer in front of my resources and server them but is it possible that I can use a single CPU with 2-cores 8-GB RAM?
Yes.
I think you're overthinking your application at this point. Premature optimization is evil. You haven't written any code yet and you're thinking about performance. It's just wasting your time.
Write the code first, then stress test it to see how much load can your application handle. Then do profiling to see where the things are slowing down. Then you optimize the code, or change your setup and maybe upgrade your hardware.
But just thinking about performance without writing and stress testing the code is just a waste of time.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install TorMySQL
You can use TorMySQL like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page