How to connect web2py with mysql on Windows 10 - python

After adding
db = DAL('mysql://admin:admin#localhost/web2py')
I got this errors..
Failure to connect, tried 5 times: Traceback (most recent call last): File "C:\Projects\web2py\gluon\packages\dal\pydal\base.py", line 457, in init self._adapter = adapter(**kwargs) File "C:\Projects\web2py\gluon\packages\dal\pydal\adapters__init__.py", line 39, in call obj = super(AdapterMeta, cls).call(*args, **kwargs) File "C:\Projects\web2py\gluon\packages\dal\pydal\adapters\base.py", line 369, in init super(SQLAdapter, self).init(*args, **kwargs) File "C:\Projects\web2py\gluon\packages\dal\pydal\adapters\base.py", line 53, in init self.reconnect() File "C:\Projects\web2py\gluon\packages\dal\pydal\connection.py", line 154, in reconnect self.connection = self.connector() File "C:\Projects\web2py\gluon\packages\dal\pydal\adapters\mysql.py", line 51, in connector return self.driver.connect(**self.driver_args) File "MySQLdb/init.py", line 81, in Connect File "MySQLdb/connections.py", line 193, in init TypeError: 'password' is an invalid keyword argument for this function
I have installed mysql, mysql-connector for python, mysql-client, python2.7 and so on
db = DAL('mysql://admin:admin#localhost/web2py')
I expecting this will be connect but not 馃槖馃槖馃槖

Try something like this
uri = mysql://user:password#host/databasename
And also, use Python 3 goodluck :)))

Related

Asn1 parsing error when trying to connect to mongo atlas

I am using MongoDB atlas for my discord bot but recently ran into an error. On the hosting (Heroku) everything works without errors, I first updated all the modules, but the error has not disappeared.
I am using motor as a driver to work with MongoDB atlas.
Checked the database connection URL, everything is correct.
Python version 3.10(on Heroku too)
Traceback (most recent call last):
File "D:\袩褉芯械泻褌褘\AkainuBot\main.py", line 23, in <module>
mongo = AsyncIOMotorClient(
File "D:\Python\lib\site-packages\motor\core.py", line 159, in __init__
delegate = self.__delegate_class__(*args, **kwargs)
File "D:\Python\lib\site-packages\pymongo\mongo_client.py", line 718, in __init__
self.__options = options = ClientOptions(
File "D:\Python\lib\site-packages\pymongo\client_options.py", line 165, in __init__
self.__pool_options = _parse_pool_options(options)
File "D:\Python\lib\site-packages\pymongo\client_options.py", line 132, in _parse_pool_options
ssl_context, ssl_match_hostname = _parse_ssl_options(options)
File "D:\Python\lib\site-packages\pymongo\client_options.py", line 98, in _parse_ssl_options
ctx = get_ssl_context(
File "D:\Python\lib\site-packages\pymongo\ssl_support.py", line 159, in get_ssl_context
ctx.load_verify_locations(certifi.where())
File "D:\Python\lib\site-packages\pymongo\pyopenssl_context.py", line 276, in load_verify_locations
self._callback_data.trusted_ca_certs = _load_trusted_ca_certs(cafile)
File "D:\Python\lib\site-packages\pymongo\ocsp_support.py", line 79, in _load_trusted_ca_certs
_load_pem_x509_certificate(cert_data, backend))
File "D:\Python\lib\site-packages\cryptography\x509\base.py", line 436, in load_pem_x509_certificate
return rust_x509.load_pem_x509_certificate(data)
ValueError: error parsing asn1 value: ParseError { kind: InvalidValue, location: ["RawCertificate::tbs_cert", "TbsCertificate::serial"] }
I've solved my problem getting the parsing asn1 value error by adding the ssl_cert_reqs option on the MongoClient (and obviously importing ssl).
dbClient = pymongo.MongoClient(uri, ssl_cert_reqs=ssl.CERT_NONE)

Cant connect to sql server with mysql-connector

I'm trying to connect to mySQL using mysql-connector and I'm getting an error:
runfile('C:/Users/Idan/Desktop/转讻谞讜转/谞讬住讜讬讬诐/idk/adding_test/connect_to_db.py', >wdir='C:/Users/Idan/Desktop/转讻谞讜转/谞讬住讜讬讬诐/idk/adding_test')
Traceback (most recent call last):
File "C:\Users\Idan\Desktop\转讻谞讜转\谞讬住讜讬讬诐\idk\adding_test\connect_to_db.py", >line 13, in
database = 'temp'
File "C:\Users\Idan\anaconda3\lib\site-packages\mysql\connector_init_.py", >line 271, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\Idan\anaconda3\lib\site->packages\mysql\connector\connection.py", line 95, in init
self._in_transaction = False
File "C:\Users\Idan\anaconda3\lib\site-packages\mysql\connector\abstracts.py", >line 985, in connect
self._open_connection()
File "C:\Users\Idan\anaconda3\lib\site->packages\mysql\connector\connection.py", line 205, in _open_connection
ssl_options.get('verify_identity') or
File "C:\Users\Idan\anaconda3\lib\site->packages\mysql\connector\connection.py", line 193, in _get_connection
if client_flags & ClientFlag.SSL:
File "C:\Users\Idan\anaconda3\lib\site-packages\mysql\connector\network.py", >line 565, in init
super(MySQLTCPSocket, self).init()
TypeError: super(type, obj): obj must be an instance or subtype of type
I have tried searching online and I can't find problem with my code (and yes the password is correct):
import mysql.connector as mysql
db = mysql.connect(
host = 'localhost',
user = 'root',
password = '10iDun7lEvy3',
database = 'temp'
)
c = db.cursor()

Python-Mysql connectivity

import mysql.connector as a
conn = a.connect(host="localhost",user="root",password="darshan",database="PAYSLIP")
#CREATE a database or connect to one
conn = a.connect('Tablename.db')
getting error:-
Traceback(most recent call last):
File "C:\Users\any.py", line 3, in <module>
a=mysql.connector.connect('Payslip.db')
File "C:\Users\Python\Python38-32\lib\site-packages\mysql\connector\__init__.py", line 265, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\connection.py", line 64, in __init__
super(MySQLConnection, self).__init__(*args, **kwargs)
TypeError: __init__() takes 1 positional argument but 2 were given
Please help...
And please explain why it is not connecting in the answer...

Twisted reactor.listenUNIX erroring after update to python 3.8

I have updated twisted from 13.0.0 to 20.3.0 and python from 2.7 to 3.8 and now twisted is throwing this not helpful error. (Ubuntu 16.04.6 LTS)
I verified the permissions of the .sock file and the directory, made sure the socket file is deleted before reactor.listenUNIX is called.
What could be the cause of this and how can I troubleshoot this issue?
class UserServer(Plugin):
def setup(self):
socket = self.parent.socket
if os.path.exists(socket):
os.remove(socket)
self.console(socket)
self.console(self.parent.config.get_umask('sock'))
self.factory = UserServerFactory(self.parent)
reactor.listenUNIX(socket, self.factory, mode=self.parent.config.get_umask('sock'))
service: 'user_server' failed to initialize
Traceback (most recent call last):
File "/home/mcgen/tools/mark2/mk2/plugins/__init__.py", line 335, in load
plugin = cls(self.parent, name, **kwargs)
File "/home/mcgen/tools/mark2/mk2/plugins/__init__.py", line 165, in __init__
self.setup()
File "/home/mcgen/tools/mark2/mk2/services/user_server.py", line 148, in setup
reactor.listenUNIX(socket, self.factory, mode=self.parent.config.get_umask('sock'))
File "/usr/local/lib/python3.8/dist-packages/twisted/internet/posixbase.py", line 397, in listenUNIX
p.startListening()
File "/usr/local/lib/python3.8/dist-packages/twisted/internet/unix.py", line 408, in startListening
self.startReading()
File "/usr/local/lib/python3.8/dist-packages/twisted/internet/abstract.py", line 435, in startReading
self.reactor.addReader(self)
File "/usr/local/lib/python3.8/dist-packages/twisted/internet/epollreactor.py", line 109, in addReader
self._add(reader, self._reads, self._writes, self._selectables,
File "/usr/local/lib/python3.8/dist-packages/twisted/internet/epollreactor.py", line 96, in _add
self._poller.register(fd, flags)
OSError: [Errno 22] Invalid argument

python elasticsearch client error: timed out while get_alias

I am new to python and elasticsearch and i am trying to run a sample application. But my elasticsearch connection shows some error. I have installed elasticsearch and started the server. In the application there is a code like this
ES_URL = ['thrift://127.0.0.1:9200']
connection = pyes.ES(ES_URL)
index = connection.indices.get_alias('staging-asset')
when .get_alias is called, it shows
Client error: timed out
Traceback (most recent call last):
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/connection.py", line 151, in _client_call
return getattr(conn.client, attr)(*args, **kwargs)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/pyesthrift/Rest.py", line 41, in execute
return self.recv_execute()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/pyesthrift/Rest.py", line 52, in recv_execute
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/protocol/TBinaryProtocol.py", line 126, in
readMessageBegin
sz = self.readI32()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/protocol/TBinaryProtocol.py", line 206, in readI32
buff = self.trans.readAll(4)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TTransport.py", line 58, in readAll
chunk = self.read(sz - have)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TTransport.py", line 159, in read
self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TSocket.py", line 103, in read
buff = self.handle.recv(sz)
timeout: timed out
Please help me to figure out the issue. Thanks in advance.
As mentioned in the comment by #omri , you might need to increase default threshold timeout-
pyes.es.ES(server, timeout=30, bulk_size=500,max_retries=10)
you can read more about here
There can also be other reasons for this timeouts. Check this and see if its still happening.
Check your mappings also

Categories