Git Product home page Git Product logo

cymysql's Introduction

cymysql's People

Contributors

bbigras avatar charles-dyfis-net avatar clarkevans avatar clelland avatar davidstory avatar j0hnsmith avatar josh4trunks avatar kaankivilcim avatar mlorenzana avatar mmartincevic avatar nakagami avatar petehunt avatar scoder avatar snjypl avatar thentenaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cymysql's Issues

CyMySQL cannot detect encoding of database

I recently encountered failure to insert unicode characters to a table even though the database and tables are already in unicode.

Here are the current conditions:

  1. Same tests works on PyMySQL but not on CyMySQL.
  2. Tests on CyMySQL only works when explicitly specifying charset='utf8mb4'

EDIT: This is in Python 3 which should automatically use unicode.

Does not seem to handle blobs larger than 8M.

I've got a files table with a MEDIUMBLOB column, which is set up to hold up to 12M large blobs. Here is a test program which consistently fails for me

import cymysql
conn = cymysql.connect(
    host='localhost',
    user='user', passwd='',
    db='test_db',
    charset='utf8',
    )
cur = conn.cursor()
for i in range(1,14):
    blob = b'x' * i * 1048576
    print('writing', i, 'len', len(blob))
    cur.execute(
        'insert into files (id, created, updated, content, name) VALUES (%s, %s, %s, %s, %s)',
        ['manual-test-'+str(i), None, None, blob, None]
        )
    conn.commit() # Fails with or without.
conn.close()

Running this program results in the following:

writing 1 len 1048576
writing 2 len 2097152
writing 3 len 3145728
writing 4 len 4194304
writing 5 len 5242880
writing 6 len 6291456
writing 7 len 7340032
writing 8 len 8388608
Traceback (most recent call last):
  File "/.../lib/python3.4/site-packages/cymysql/cursors.py", line 128, in execute
    self._query(query)
  File "/.../lib/python3.4/site-packages/cymysql/cursors.py", line 234, in _query
    conn.query(q)
  File "/.../lib/python3.4/site-packages/cymysql/connections.py", line 340, in query
    self._execute_command(COM_QUERY, sql)
  File "/.../lib/python3.4/site-packages/cymysql/connections.py", line 440, in _execute_command
    self._send_command(command, sql)
  File "/.../lib/python3.4/site-packages/cymysql/connections.py", line 436, in _send_command
    self.socket.sendall(prelude + sql)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "dbtest.py", line 21, in <module>
    ['manual-test-'+str(i), None, None, blob, None]
  File "/.../lib/python3.4/site-packages/cymysql/cursors.py", line 133, in execute
    self.errorhandler(exc, value)
  File "/.../lib/python3.4/site-packages/cymysql/cursors.py", line 35, in errorhandler
    self.connection.errorhandler(self, errorclass, errorvalue)
  File "/.../lib/python3.4/site-packages/cymysql/connections.py", line 116, in errorhandler
    raise Error(errorclass, errorvalue)
cymysql.err.Error: (<class 'BrokenPipeError'>, BrokenPipeError(32, 'Broken pipe'))

I've spent a lot of time trying to configure my DB thinking this is a MySQL setup problem, and I ended up with the following my.cnf:

max_allowed_packet=1G
innodb_buffer_pool_size = 256M
innodb_log_file_size = 256M
bulk_insert_buffer_size = 16M

This should be sufficient.

However, the MySQL documentation states that both server and client have to support large packet sizes (see documentation link). Above configuration is server side only, with cymysql being the client's driver.

Looking at the PyMySQL implementation of the connection setup (source code) I see a default parameter max_allowed_packet=16*1024*1024 which is missing from the CyMySQL implementation (source code). So I switched to import pymysql and everything works as expected!

I think that this issue needs to be investigated, and probably fixed by CyMySQL.

LookupError: unknown encoding: utf8mb4

I added ?charset=utf8mb4 to my sqlalchemy create_engine().

Using CyMySQL, the following error shows:

  File "redacted_path\lib\site-packages\cymysql\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "redacted_path\lib\site-packages\cymysql\connections.py", line 248, in __init__
    self._connect()
  File "redacted_path\lib\site-packages\cymysql\connections.py", line 416, in _connect
    self._request_authentication()
  File "redacted_path\lib\site-packages\cymysql\connections.py", line 468, in _request_authentication
    user = self.user.encode(self.charset)
LookupError: unknown encoding: utf8mb4

By just changing engine to PyMySQL, everything works perfectly.

EDIT: I am using cymysql==0.9.12

Missing CR constants

'cymysql.constants.CR' is missing. It does not break my current code, but I don't know in the future.
The constants can be copied from 'pymysql.constants.CR'
Thanks.

Exception closing connection

I'm running cymysql (0.8.5) and SQLAlchemy (0.9.8) for a MySQL db. When the web server (Python 3.4, pyramid 1.5.1) is inactive and just sitting for longer periods of time, I repeatedly see the following exception occur:

ERROR [sqlalchemy.pool.QueuePool][b'uWSGIWorker1Core0'] Exception closing connection <cymysql.connections.Connection object at 0x7fb2c969fef0>
Traceback (most recent call last):
  File "/var/www/.../lib64/python3.4/site-packages/sqlalchemy/pool.py", line 290, in _close_connection
    self._dialect.do_close(connection)
  File "/var/www/.../lib64/python3.4/site-packages/sqlalchemy/engine/default.py", line 426, in do_close
    dbapi_connection.close()
  File "/var/www/.../lib64/python3.4/site-packages/cymysql/connections.py", line 271, in close
    self.socket.sendall(send_data)
BrokenPipeError: [Errno 32] Broken pipe

Is this a problem? A configuration issue?

cymysql.err.InternalError: (1043, 'Bad handshake')

django == 3.0.5
django-cymysql == 3.0.0
cymysql == 0.9.14
mysql == 5.7.23

Traceback (most recent call last):
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/mysql_cymysql/base.py", line 232, in get_new_connection
return Database.connect(**conn_params)
File "/home/linux/py3env/lib/python3.7/site-packages/cymysql/init.py", line 84, in Connect
return Connection(*args, **kwargs)
File "cymysql/connections.py", line 248, in cymysql.connections.Connection.init
File "cymysql/connections.py", line 414, in cymysql.connections.Connection._connect
File "cymysql/connections.py", line 500, in cymysql.connections.Connection._request_authentication
File "cymysql/connections.py", line 419, in cymysql.connections.Connection.read_packet
File "cymysql/packet.pyx", line 65, in cymysql.packet.MysqlPacket.init
File "cymysql/err.py", line 149, in cymysql.err.raise_mysql_exception
File "cymysql/err.py", line 144, in cymysql.err._check_mysql_exception
cymysql.err.InternalError: (1043, 'Bad handshake')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/linux/py3env/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/linux/py3env/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/home/linux/py3env/lib/python3.7/site-packages/django/core/management/base.py", line 458, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/migrations/executor.py", line 18, in init
self.loader = MigrationLoader(self.connection)
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/migrations/loader.py", line 49, in init
self.build_graph()
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 76, in applied_migrations
if self.has_table():
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 260, in cursor
return self._cursor()
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 236, in _cursor
self.ensure_connection()
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/django/db/backends/base/base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/linux/py3env/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/linux/py3env/lib/python3.7/site-packages/mysql_cymysql/base.py", line 232, in get_new_connection
return Database.connect(**conn_params)
File "/home/linux/py3env/lib/python3.7/site-packages/cymysql/init.py", line 84, in Connect
return Connection(*args, **kwargs)
File "cymysql/connections.py", line 248, in cymysql.connections.Connection.init
File "cymysql/connections.py", line 414, in cymysql.connections.Connection._connect
File "cymysql/connections.py", line 500, in cymysql.connections.Connection._request_authentication
File "cymysql/connections.py", line 419, in cymysql.connections.Connection.read_packet
File "cymysql/packet.pyx", line 65, in cymysql.packet.MysqlPacket.init
File "cymysql/err.py", line 149, in cymysql.err.raise_mysql_exception
File "cymysql/err.py", line 144, in cymysql.err._check_mysql_exception
django.db.utils.InternalError: (1043, 'Bad handshake')

Lost connection to MySQL server during query (after 0.8.2 -> 0.8.4)

After upgrading to 0.8.4 I get this error frequent. I did a new 0.8.2 install via setup.py and it worked again. Then I did a install of 0.8.3 via setup.py and I got this error.
This error is not exact reproducible. But it occurs after "many" select queries. It look likes it happens with a bigger select query (more data to return).

File "cymysql/cursors.py", line 259, in cymysql.cursors.DictCursor.execute (cymysql/cursors.c:6594)
File "cymysql/cursors.py", line 133, in cymysql.cursors.Cursor.execute (cymysql/cursors.c:4285)
File "cymysql/cursors.py", line 35, in cymysql.cursors.Cursor.errorhandler (cymysql/cursors.c:1639)
File "cymysql/connections.py", line 118, in cymysql.connections.Connection.errorhandler (cymysql/connections.c:4189)
File "cymysql/cursors.py", line 128, in cymysql.cursors.Cursor.execute (cymysql/cursors.c:4093)
File "cymysql/cursors.py", line 234, in cymysql.cursors.Cursor._query (cymysql/cursors.c:6219)
File "cymysql/connections.py", line 341, in cymysql.connections.Connection.query (cymysql/connections.c:9315)
File "cymysql/packet.pyx", line 285, in cymysql.packet.MySQLResult.init (cymysql/packet.c:6392)
File "cymysql/packet.pyx", line 295, in cymysql.packet.MySQLResult.read_rest_rowdata_packet (cymysql/packet.c:6561)
File "cymysql/packet.pyx", line 61, in cymysql.packet.MysqlPacket.init (cymysql/packet.c:1470)
File "cymysql/packet.pyx", line 87, in cymysql.packet.MysqlPacket.__recv_packet (cymysql/packet.c:1838)
cymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')

It is always a select statement (where and order by). The connection to mysql is via tcp-ip (from one virtual machine to another (virtualbox), same hardware).
I am running:
client:

Kernel : Linux 3.13.0-63-generic (x86_64)
Compiled : PyMySQL#103-Ubuntu SMP Fri Aug 14 21:42:59 UTC 2015
Default C Compiler : GNU C Compiler version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
Distribution : Ubuntu 14.04.3 LTS

python: 3.4
cython: 0.23.3

server:
-Version-
Kernel : Linux 3.13.0-63-generic (x86_64)
Compiled : PyMySQL#103-Ubuntu SMP Fri Aug 14 21:42:59 UTC 2015
Default C Compiler : GNU C Compiler version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
Distribution : Ubuntu 14.04.3 LTS

mysql: mariadb 5.5.44

Package requires Crypto module, but makes no mention of this.

While connecting to a local mysql instance, running in docker, I encountered this error. I checked through the pymysql docs and the readme provided here, and found no mention of pycrypto (or the more current pycryptodome) in any capacity, much less as a necessary package.

I checked the code, and it seems like it's not always needed, though I only took a quick look at it. GitHub does not support searching through forked repositories, so I cannot tell if it's used anywhere other than connections.py:535.

If it's always needed, then it should probably be added to setup.py as a dependency.
If it's not always needed, then it could be added to setup.py as an optional dependency.

In either case, I'd be happy to submit a patch to that effect.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/venv/xxx/lib/python3.7/site-packages/cymysql/__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "/path/to/venv/xxx/lib/python3.7/site-packages/cymysql/connections.py", line 248, in __init__
    self._connect()
  File "/path/to/venv/xxx/lib/python3.7/site-packages/cymysql/connections.py", line 416, in _connect
    self._request_authentication()
  File "/path/to/venv/xxx/lib/python3.7/site-packages/cymysql/connections.py", line 513, in _request_authentication
    self._caching_sha2_authentication2(auth_packet, next_packet)
  File "/path/to/venv/xxx/lib/python3.7/site-packages/cymysql/connections.py", line 535, in _caching_sha2_authentication2
    from Crypto.PublicKey import RSA
ModuleNotFoundError: No module named 'Crypto'
```

cymysql.err.InternalError: (1043, 'Bad handshake')

Server version: 5.5.56-MariaDB MariaDB Server

Traceback (most recent call last):
File "D:/PycharmProjects/cymysqlTest/mm.py", line 3, in
conn = cymysql.connect(host='127.0.0.1',port=3306,user="root",passwd="1123",db="ssp",charset='utf8')
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql_init_.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql\connections.py", line 222, in init
self._connect()
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql\connections.py", line 388, in _connect
self._request_authentication()
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql\connections.py", line 460, in _request_authentication
auth_packet = MysqlPacket(self)
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql\packet.py", line 67, in init
raise_mysql_exception(self.__data)
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql\err.py", line 142, in raise_mysql_exception
_check_mysql_exception(errinfo)
File "C:\Users\Chin\venv\cymysqlTest\lib\cymysql\err.py", line 138, in _check_mysql_exception
raise InternalError(errno, errorvalue)
cymysql.err.InternalError: (1043, 'Bad handshake')

Limited support: authentication plugins

Hi,

I encountered the following error lately:
NotImplementedError: mysql_clear_password authentication plugin is not implemented

Found out that CyMySQL only support mysql_native_password and caching_sha2_password.

PyMySQL , on the the hand, support other plugins like sha256_password, mysql_old_password, mysql_clear_password, etc. See (https://github.com/PyMySQL/PyMySQL/blob/f0bbe54ef7f977c8cc8a55f583e85d06bea44e7c/pymysql/connections.py#L881)

It would be better if CyMySQL support can be extended since this library is fast compared to PyMySQL.

Cheers!

BrokenPipeError: [Errno 32] Broken pipe

Broken pipe error occurs when the flask application is relatively busy. Then, we need to manually restart the application or handle the recovery of the application in code. Could you fix this error and add an automatically recover feature on the production server? I struggled with this never-ending production error.

App 3411705 output: [ pid=3411705, time=2020-06-28 07:15:12,677 ]: Exception on /api/auth [POST]
App 3411705 output: Traceback (most recent call last):
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 130, in execute
App 3411705 output:     self._query(query)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 240, in _query
App 3411705 output:     conn.query(q)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/connections.py", line 343, in query
App 3411705 output:     self._execute_command(COMMAND.COM_QUERY, sql)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/connections.py", line 440, in _execute_command
App 3411705 output:     self.socket.sendall(prelude + sql)
App 3411705 output: BrokenPipeError: [Errno 32] Broken pipe
App 3411705 output: 
App 3411705 output: During handling of the above exception, another exception occurred:
App 3411705 output: 
App 3411705 output: Traceback (most recent call last):
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
App 3411705 output:     cursor, statement, parameters, context
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
App 3411705 output:     cursor.execute(statement, parameters)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 135, in execute
App 3411705 output:     self.errorhandler(exc, value)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 37, in errorhandler
App 3411705 output:     self.connection.errorhandler(self, errorclass, errorvalue)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/connections.py", line 115, in errorhandler
App 3411705 output:     raise Error(errorclass, errorvalue)
App 3411705 output: cymysql.err.Error: (<class 'BrokenPipeError'>, BrokenPipeError(32, 'Broken pipe'))
App 3411705 output: 
App 3411705 output: The above exception was the direct cause of the following exception:
App 3411705 output: 
App 3411705 output: Traceback (most recent call last):
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app
App 3411705 output:     response = self.full_dispatch_request()
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request
App 3411705 output:     rv = self.handle_user_exception(e)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception
App 3411705 output:     reraise(exc_type, exc_value, tb)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
App 3411705 output:     raise value
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
App 3411705 output:     rv = self.dispatch_request()
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
App 3411705 output:     return self.view_functions[rule.endpoint](**req.view_args)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/views.py", line 88, in view
App 3411705 output:     return self.dispatch_request(*args, **kwargs)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/flask/views.py", line 158, in dispatch_request
App 3411705 output:     return meth(*args, **kwargs)
App 3411705 output:   File "ujian_app/api/auth.py", line 53, in ujian_app.api.auth.AuthAPI.post
App 3411705 output:   File "ujian_app/repository/genericrepository.py", line 33, in ujian_app.repository.genericrepository.GenericRepository.find_by_id
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 1021, in get
App 3411705 output:     return self._get_impl(ident, loading.load_on_pk_identity)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 1138, in _get_impl
App 3411705 output:     return db_load_fn(self, primary_key_identity)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 287, in load_on_pk_identity
App 3411705 output:     return q.one()
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3436, in one
App 3411705 output:     ret = self.one_or_none()
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3405, in one_or_none
App 3411705 output:     ret = list(self)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3481, in __iter__
App 3411705 output:     return self._execute_and_instances(context)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3506, in _execute_and_instances
App 3411705 output:     result = conn.execute(querycontext.statement, self._params)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1020, in execute
App 3411705 output:     return meth(self, multiparams, params)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
App 3411705 output:     return connection._execute_clauseelement(self, multiparams, params)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_clauseelement
App 3411705 output:     distilled_params,
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1324, in _execute_context
App 3411705 output:     e, statement, parameters, cursor, context
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1518, in _handle_dbapi_exception
App 3411705 output:     sqlalchemy_exception, with_traceback=exc_info[2], from_=e
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
App 3411705 output:     raise exception
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
App 3411705 output:     cursor, statement, parameters, context
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
App 3411705 output:     cursor.execute(statement, parameters)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 135, in execute
App 3411705 output:     self.errorhandler(exc, value)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 37, in errorhandler
App 3411705 output:     self.connection.errorhandler(self, errorclass, errorvalue)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/connections.py", line 115, in errorhandler
App 3411705 output:     raise Error(errorclass, errorvalue)
App 3411705 output: sqlalchemy.exc.DBAPIError: (cymysql.err.Error) (<class 'BrokenPipeError'>, BrokenPipeError(32, 'Broken pipe'))
App 3411705 output: [SQL: SELECT akun.nama AS akun_nama, akun.username AS akun_username, akun.password AS akun_password, akun.`role` AS akun_role 
App 3411705 output: FROM akun 
App 3411705 output: WHERE akun.username = %s]
App 3411705 output: [parameters: ... ]
App 3411705 output: (Background on this error at: http://sqlalche.me/e/dbapi)
App 3411705 output: [ pid=3411705, time=2020-06-28 07:15:14,350 ]: Exception on /api/auth [POST]
App 3411705 output: Traceback (most recent call last):
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 130, in execute
App 3411705 output:     self._query(query)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/cursors.py", line 240, in _query
App 3411705 output:     conn.query(q)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/connections.py", line 343, in query
App 3411705 output:     self._execute_command(COMMAND.COM_QUERY, sql)
App 3411705 output:   File "/home/guidecit/virtualenv/essayscoringapp/3.7/lib/python3.7/site-packages/cymysql/connections.py", line 440, in _execute_command
App 3411705 output:     self.socket.sendall(prelude + sql)
App 3411705 output: BrokenPipeError: [Errno 32] Broken pipe

Duda

### Donde leo la documentación de esta librería

How do you enable local infile?

PyMySQL has a connection parameter named local_infile which can be set to True to enable uploading of files. I don't see how to do the same thing in CyMySQL.

data is returned as NULL when use_unicode=0

Using cymysql 0.8.6, Python 2.7.11 on Fedora 23, and MariaDB 10.0.23, if use_unicode is not set to True, basic textual results return None:

import cymysql

print cymysql.__version__

conn1 = cymysql.connect(use_unicode=1)
conn2 = cymysql.connect()

def test(conn):
    cursor = conn.cursor()

    cursor.execute("SELECT 'any old text'")
    print cursor.fetchall()

    cursor.execute("SELECT @@tx_isolation")

    print cursor.fetchall()

test(conn1)
test(conn2)

output:

$ python test3.py 
0.8.6
[(u'any old text',)]
[(u'REPEATABLE-READ',)]
[(None,)]
[(None,)]

this seems pretty serious can you please confirm? I can close my downstream issue then.

Error Build with Cython

Cannot build cymsql with cython

running build_ext building 'cymysql.packet' extension creating build/temp.macosx-10.13-x86_64-3.6 creating build/temp.macosx-10.13-x86_64-3.6/cymysql clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c cymysql/packet.c -o build/temp.macosx-10.13-x86_64-3.6/cymysql/packet.o cymysql/packet.c:806:7: warning: this function declaration is not a prototype [-Wstrict-prototypes] int errno; ^ /usr/include/sys/errno.h:81:24: note: expanded from macro 'errno' #define errno (*__error())

To support IPv6

When I try to connect my mysql via an ipv6 address, It fails.
However the origin PyMySQL can do it after PyMySQL@b15c673 with
issues PyMySQL#118
Can you also fix it, and update the pypi?

And This is my temporary solution.

diff -Naur cymysql/connections.py cymysql-ipv6/connections.py
--- cymysql/connections.py    2017-06-10 03:51:56.000000000 -0400
+++ cymysql-ipv6/connections.py    2017-10-27 05:12:51.125249151 -0400
@@ -398,13 +398,14 @@
                 self.host_info = "Localhost via UNIX socket"
                 if DEBUG: print('connected using unix_socket')
             else:
-                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-                t = sock.gettimeout()
-                sock.settimeout(self.connect_timeout)
-                sock.connect((self.host, self.port))
+                sock = socket.create_connection((self.host, self.port), self.connect_timeout)
                 self.host_info = "socket %s:%d" % (self.host, self.port)
                 if DEBUG: print('connected using socket')
-            sock.settimeout(t)
         except socket.error as e:
             sock.close()
             raise OperationalError(2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e.args[0]))

Sync with current PyMySQL

This project started as a fork of PyMySQL, but it hasn't been synced in a very long time. Are there any plans to merge the current PyMySQL code in? There are a number of new features that I'd like to see made available.

InternalError: (1043, u'Bad handshake')

Issue:
File "/root/ssr/cymysql/init.py", line 84, in Connect
return Connection(*args, **kwargs)
File "/root/ssr/cymysql/connections.py", line 245, in init
self._connect()
File "/root/ssr/cymysql/connections.py", line 413, in _connect
self._request_authentication()
File "/root/ssr/cymysql/connections.py", line 497, in _request_authentication
auth_packet = self.read_packet()
File "/root/ssr/cymysql/connections.py", line 418, in read_packet
return MysqlPacket(self)
File "/root/ssr/cymysql/packet.py", line 65, in init
raise_mysql_exception(self.__data)
File "/root/ssr/cymysql/err.py", line 149, in raise_mysql_exception
_check_mysql_exception(errinfo)
File "/root/ssr/cymysql/err.py", line 144, in _check_mysql_exception
raise InternalError(errno, errorvalue)
InternalError: (1043, u'Bad handshake')

Commit: The lastest 2287d13

Yes, this problem has arisen again. Previous issue: #22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.