Arch Linux MySQL HTTP Plugin missing? - mysql

I'm trying to revive an undocumented python server at work and I'm running into an issue with a missing file. When attempting to connect to the SQL DB with the credentials I've provided, I run into the following error:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
self.connect()
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 233, in get_new_connection
return Database.connect(**conn_params)
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/MySQLdb/__init__.py", line 84, in Connect
return Connection(*args, **kwargs)
File "/home/user/Projects/project/venv/lib/python3.9/site-packages/MySQLdb/connections.py", line 179, in __init__
super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2059, 'Plugin http could not be loaded: /usr/lib/mysql/plugin/http.so: cannot open shared object file: No such file or directory')
Sure enough, there is no http.so file at that location, though there is a healthy bunch of others. I cannot find any documentation on why this may be or where I'm supposed to get it.
I'm using Arch Linux, and just installed from the AUR using sudo pacman -S mysql. This is just an alias for mariadb from what I can tell, but I don't think that's an issue.
Is this shared object something I can get somewhere? Not sure really what to do here.

Came across a thread for HeidiSQL, which from what I read is a MySQL admin tool of sorts. Anyways, a user had the same issue over there, and someone responded with this:
Just don't use any protocol prefix in the hostname, unless you know it's required and correct. In most cases there must be just the hostname or an ip address, without a protocol.
https://www.heidisql.com/forum.php?t=27104#p34471
Sure enough, I was using http:// in my hostname. Removing that works just fine, though isn't so much of a solution as a workaround.

Related

Two Django projects using same database

I have a database that is being used by my django project and a php project. So now i am about to add another separate django project which will use the same database.
After setting up the project i wrote models.py and when i tried to run server it is giving error: -
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7fcedb0338c0>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check_migrations()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 163, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 299, in build_graph
parent = self.check_key(parent, key[0])
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 160, in check_key
raise ValueError("Dependency on app with no migrations: %s" % key[0])
ValueError: Dependency on app with no migrations: apiapp
It is not allowing me to run python manage.py migrate.
How to cope up with this type of problem.
Make you models and create migrations.
After this run fake initial migration

Tryton ERP MySQL installation

I'm trying to install Tryton ERP with MySQL as the database. It's not quite clear what you are meant to do.
From the config documentation you simply supply the uri to the database under the [database] section:
[database]
uri = mysql://user:pass#localhost:3306
However running trytond -v -c /home/user/.config/tryton/3.8/tryton.conf does not seem to get it working. When trying to access the 127.0.0.1:8050 where I've got Tryton running, I simply get 127.0.0.1 - - [23/Nov/2015 16:55:10] code 404, message File not found
One would assume, Tryton either installs the database on its own or you need to create yourself somehow but I didn't see any documentation surrounding that.
I've also trying adding a database through the Tryton GUI, it encounters the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tryton/gui/window/dbcreate.py", line 65, in server_change
common.refresh_langlist(self.combo_language, host, port)
File "/usr/local/lib/python2.7/dist-packages/tryton/common/common.py", line 253, in refresh_langlist
lang_list = rpc.db_exec(host, port, 'list_lang')
File "/usr/local/lib/python2.7/dist-packages/tryton/rpc.py", line 57, in db_exec
result = getattr(connection.common.db, method)(None, None, *args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/local/lib/python2.7/dist-packages/tryton/jsonrpc.py", line 271, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/local/lib/python2.7/dist-packages/tryton/jsonrpc.py", line 134, in close
return json.loads(self.data, object_hook=object_hook)
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 505, in loads
return cls(encoding=encoding, **kw).decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 2 (char 1)
I've got the prerequisites installed that were listed here and MySQL-python package installed, should there be anything else?
You should create a database on MySQL with it's own tools. Once the database is created you must initialize it using the following command:
trytond -c <config_file> -d <database name> --all
See for complete reference:
http://doc.tryton.org/3.8/trytond/doc/topics/setup_database.html#topics-setup-database.
Once finished, the server will ask for an admin password. Once entered you can conect using the tryton client with the admin user and the entered password.
In order to access tryton from web client you must install and configure the sao web interface, that can be found on:
https://www.npmjs.com/package/tryton-sao

MySQL server has gone away (code 2006)

I sow post on
How to enable MySQL client auto re-connect with MySQLdb?
I had the same problem, I use pythonanywhere.com and when I write p.save() I had error like below.
It says something about updating mysql to fix it, but I don't know what code or shell commands I need to write.
Can you help me?
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
force_update=force_update, update_fields=update_fields)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py", line 570, in save_base
with transaction.commit_on_success_unless_managed(using=using, savepoint=False):
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py", line 280, in __enter__
connection.set_autocommit(False)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 340, in set_autocommit
self._set_autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
self.connection.autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 461, in _set_autocommit
self.connection.autocommit(autocommit)
File "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 243, in autocommit
_mysql.connection.autocommit(self, on)
OperationalError: (2006, 'MySQL server has gone away')
Your connection to the database was closed because it was idle for too long. From the traceback, it looks like you were doing your queries interactively. If you know that you've been idle for more than about 5 min, you should do this:
from django.db import connection; connection.close()
I solved the problem inserting this code where the connection will need to be restored and refreshed:
try:
cursor = connections['default'].cursor()
db = cursor.db
assert issubclass(db.__class__, BaseDatabaseWrapper)
if db.connection is None or not db.is_usable():
db.close_if_unusable_or_obsolete()
with db.wrap_database_errors:
db.connect()
logger.info('Restoring the Mysql Connection')
except Exception as e:
logger.exception('DB Connection error')
Please notice that I use connections['default'] because I have multiple databases configured so you can set a specific connection, notice also that I use db.is_usable() so to call the .ping() to allow to restore a connection when is possible instead of always closing the connection.

Mercurial https clone: "abort: error: (...) wrong version number"

I have problem with mercurial on OS X 10.9.1
I have a repository on bitbucket with couple files, when I'm trying to clone it I'm getting an error:
mac-mini-jakub:testrepo kubeczek$ hg clone https://kubecz3k#bitbucket.org/kubecz3k/test
abort: error: _ssl.c:507: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
I have installed Mercurial 2.8.2 for MacOS X 10.9 from https://www.mercurial-scm.org/downloads/
I'm pretty sure that on the side of the bitbucket everything is ok, because I have no problem on linux machine.
here is the full traceback:
mac-mini-jakub:testrepo kubeczek$ hg clone https://kubecz3k#bitbucket.org/kubecz3k/test --traceback
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 133, in _runcatch
return _dispatch(req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 806, in _dispatch
cmdpats, cmdoptions)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 585, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 897, in _runcommand
return checkargs()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 868, in checkargs
return cmdfunc()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 803, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 512, in check
return func(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/commands.py", line 1286, in clone
branch=opts.get('branch'))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 268, in clone
srcpeer = peer(ui, peeropts, source)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 122, in peer
return _peerorrepo(rui, path, create).peer()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 102, in _peerorrepo
obj = _peerlookup(path).instance(ui, path, create)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 238, in instance
inst._fetchcaps()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 57, in _fetchcaps
self.caps = set(self._call('capabilities').split())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 171, in _call
fp = self._callstream(cmd, **args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/httppeer.py", line 118, in _callstream
resp = self.urlopener.open(req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/url.py", line 368, in https_open
return self.do_open(self._makeconnection, req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/keepalive.py", line 257, in do_open
raise urllib2.URLError(err)
URLError: <urlopen error [Errno 1] _ssl.c:507: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number>
abort: error: _ssl.c:507: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
My Python version is:
mac-mini-jakub:~ kubeczek$ python -V
Python 2.7.6
And SSL:
>>> print _ssl.OPENSSL_VERSION
OpenSSL 0.9.8y 5 Feb 2013
I will appreciate every help, thanks!
You probably have to disable TLS, read this
To do so, add this to ~/.hgrc
[ui]
tls = False
more information about SSL and TLS here
There is another cause. It might not have been your problem, but it should be listed here as well, for the case others encounter this problem:
If you are behind a proxy and your proxy settings are incorrect, this error message appears as well. God knows why...
Example: you have the following config
[http_proxy]
no = localhost,127.0.0.1
host = 1.2.3.4:8080
user = myusername
passwd = oldpassword
The oldpassword might be obsolet (you have forgotten to change it). Then the very same SSL wrong version error appears. It does absolutly make no sense at all (at least to me), but I reproduced this issue with mercurial 3.6.2. Correcting the proxy settings fixes everything.
Not exactly a direct solution but good workaround:
With strong suggestion that the problem lies is ssl I have switched to ssh(https://confluence.atlassian.com/pages/viewpage.action?pageId=270827678) and now everything works. So from a practical point of view for me this problem is solved.
I had this problem for some bitbucket repositories (but not all). I found that, as per the traceback, setting --config ui.clonebundles=false worked.
hg clone --config ui.clonebundles=false https://bitbucket.org/me/myrepo
made the clone much slower mind you.
[edit] -- Although, see my comment on #UniversE's answer above, the actual problem was to do with an atlassian subdomain not being on my squid proxy's whitelist. phew, that was hard to debug.
As one of the question's comments suggested, switching from https to ssh fixed it for me
You have to disable clonebundle from system wide mercurial config file or own config file.
To do, add following lines to /etc/mercurial/hgrc or ~/.hgrc
# system-wide mercurial configuration file
# See hgrc(5) for more information
[ui]
clonebundles = False

Pyramid, Python3, SQLAlchemy and MySQL

I want Pyramid, Python3, SQLAlchemy and MySQL to play nice on a single machine. This question has been asked before, but it was a long enough time ago that I'm hoping the answer has changed...
Questions:
What driver works for getting a Python 3 Pyramid app to talk nicely to MySQL via SQLAalchemy? Is this even possible?
I've gotten quite far in this project thinking it would be a simple thing to switch out databases, now I'm a bit stuck and downgrading to Python 2.7 is not something I want to have to go through. So my second question is:
If there is no way to talk to MySQL nicely without downgrading, is there a database that Python 3 is ready for (besides SQLite)?
Or lastly, how would I overcome any of the problems mentioned in the 'Stuff I've Tried' section below?
Stuff I've Tried:
PyMySQL
I have PyMySQL installed and I even got it to complain about incorrect passwords and a missing database so it's getting something right. But when I tried to initialize my database (using initialize_foo_db) everything went sour:
2013-02-06 17:18:31,282 INFO [sqlalchemy.engine.base.Engine][MainThread] b'SELECT DATABASE()'
2013-02-06 17:18:31,282 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
Traceback (most recent call last):
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 719, in _do_get
return self._pool.get(wait, self._timeout)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/util/queue.py", line 137, in get
raise Empty
sqlalchemy.util.queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "../bin/initialize_mega_db", line 9, in <module>
load_entry_point('mega==0.0', 'console_scripts', 'initialize_mega_db')()
File "/home/sheena/MegaCatalogue/env/mega/mega/scripts/initializedb.py", line 46, in main
Base.metadata.create_all(engine)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/schema.py", line 2567, in create_all
tables=tables)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 2301, in _run_visitor
conn = self.contextual_connect(close_with_result=False)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 2492, in contextual_connect
self.pool.connect(),
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 224, in connect
return _ConnectionFairy(self).checkout()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 387, in __init__
rec = self._connection_record = pool._do_get()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 741, in _do_get
con = self._create_connection()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 188, in _create_connection
return _ConnectionRecord(self)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 273, in __init__
pool.dispatch.first_connect.exec_once(self.connection, self)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/event.py", line 279, in exec_once
self(*args, **kw)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/event.py", line 288, in __call__
fn(*args, **kw)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/strategies.py", line 168, in first_connect
dialect.initialize(c)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/dialects/mysql/base.py", line 1999, in initialize
default.DefaultDialect.initialize(self, connection)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/default.py", line 177, in initialize
self._get_default_schema_name(connection)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/dialects/mysql/base.py", line 1964, in _get_default_schema_name
return connection.execute('SELECT DATABASE()').scalar()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 1449, in execute
params)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 1628, in _execute_text
statement, parameters
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 1691, in _execute_context
context)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/default.py", line 333, in do_execute
cursor.execute(statement, parameters)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/PyMySQL3-0.5-py3.2.egg/pymysql/cursors.py", line 108, in execute
query = query % escaped_args
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
oursql
I tried installing oursql using pip install -r file
where file contains:
#oursql==0.9.3 but need special Python 3 build https://bugs.launchpad.net/oursql/+bug/1051512
https://launchpad.net/oursql/py3k/py3k-0.9.3/+download/oursql-0.9.3.zip
pyramid==1.3.4
And I got:
oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
myconnpy
This installs without error but I can't seem to find out what I should tell SQLAlchemy to look for. In the appropriate settings.ini file I have tried:
sqlalchemy.url = mysql+myconnpy://...
as well as a bunch of other things. Google is failing me on this one...
UPDATE - a semblance of progress
I've managed to install oursql build dependencies:
sudo aptitude install python-pip libmysqlclient-dev
I then downloaded oursql0.9.3 and ran:
setup.py install
The output was this:
cython not found, using previously-cython'd .c file.
running install
running build
running build_ext
running install_lib
copying build/lib.linux-x86_64-3.2/oursql.cpython-32mu.so -> /home/sheena/MegaCatalogue/env/lib/python3.2/site-packages
running install_egg_info
Writing /path/to/virtualenv/foo/lib/python3.2/site-packages/oursql-0.9.3.egg-info
I opened a shell and apparently the module doesn't exist - it can't be imported anyway. But for some reason it is listed if I say help() then modules