Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all 387 articles
Browse latest View live

MySQL C API installation Fails (no replies)

$
0
0
Attempting to build mysql-connector-python with the C extensions enabled.

Python module builds correctly, but warns:

"MySQL C API installation invalid (my_config.h not found)"

I've tried with both mysql-connector-c-6.1.6-1.el17.src.rpm and mysql-connector-c-6.1.6-src

Any guidance? Any help would be greatly appreciated.

Platform is Centos6.5 with mysql-devel installed.



Also, version 2.1.1 was a February release, according to documentation. Why is the latest version available via PIP still only 2.0.4?

Connection problem, error message (no replies)

$
0
0
Hi, I would appreciate some help. I have been using a mySQL database called "evette" in my veterinary clinic. This database is installed on the reception computer and I can access it from my consulting room laptop over a wireless network.

I have recently bought new laptops with Windows 8.1 to replace these computers and have MySQL and the database installed successfully on the reception laptop. I have the 2 computers sharing a wireless network. When I try to connect to the database on the reception computer from my consulting room laptop I get the following error message:

Traceback (most recent call last):
File "launch.py", line 304, in <module>
File "db.pyc", line 177, in CreateDatabase
File "db.pyc", line 155, in SendSQL
File "MySQLdb\cursors.pyc", line 166, in execute
File "MySQL\connections.pyc", line 35 in defaulterrorhandler
_mysql_exceptions.OperationalError: (1044, "Acess denied for user 'Reception'@'%' to database 'evette'")

Can anyone advise me what the problem is? I have a limited understanding of these things! Thanks for any suggestions.

during string formatting, Wrong number of arguments (no replies)

$
0
0
(1) Here is prove that it does work:

>>> cnx = mysql.connector.connect(............)
>>> cur = cnx.cursor()
>>> cur.execute("SELECT %(name)s, %(name)s", {'name': 'ham'})
>>> cur.fetchall()
[(u'ham', u'ham')]

Upgrade to Python Connector Fails (3 replies)

$
0
0
Windows 8.1
MySQL 5.6.16 64 bit

Upgrade of Connector/Python 2.7.1.0.12 to 2.7.1.1.5 fails.

It cannot find python.exe in D:\Python27

I have set the path D:\Python27 in environment variables and can run it.

Previously I had uninstalled the version of Python that was in D:\Python27 and installed Anaconda version of Python instead.
That seemed to explain why the upgrade failed.

I reinstalled a new version of Python 2.7.2, 32 bit, msi from python.org in D:\Python27 and set the path variable to D:\Python27.

I rebooted and tried again to upgrade the connector but the error remains that it still cannot find Python 2.7.2

Error Message:
2: Action 13:59:21: INSTALL.
2: 1: MySQL Connector Python v1.1.5 for Python v2.7 2: {B68B3870-6511-4D36-97BD-189A761A2728}
2: Action 13:59:21: FindRelatedProducts. Searching for related applications
2: Action 13:59:21: AppSearch. Searching for installed applications
2: Action 13:59:21: SetInstallDir.
2: Action 13:59:21: LaunchConditions. Evaluating launch conditions
2: Python v2.7 not found. We only support Python installed using the Microsoft Windows Installer (MSI) downloaded from http://www.python.org/download/. Please check the Connector/Python manual on http://dev.mysql.com/doc/ for more information.
2: 1: MySQL Connector Python v1.1.5 for Python v2.7 2: {B68B3870-6511-4D36-97BD-189A761A2728} 3: 3
2:
2: Final actions.
2: Update failed

ImportError: No module named connect‏ (3 replies)

$
0
0
I have been trying to install the MySQL Connect module for a day and a half.

First I got an error saying that "No module named mysql" was installed. After a lot of trial and error I got passed that. I realized that because I have python installed in /usr/local that I needed to build and then install the library into site-packages where Python was looking. But now it appears that the submodule "connect" cannot be located.

Some people have suggested online that I needed to make sure the module was added to the system path by doing this:

import sys
sys.path.insert(1,'//usr/local/lib/python2.4/site-packages/mysql')
import mysql

Some have suggested that I needed to edit the __init__.py file in /mysql/ with this:
from pkgutil import extend_path
path = extend_path(path, name)

But after I built and then installed pointing to my site-packages directory the __init__.py file in /usr/local/lib/python2.4/site-packages/mysql/ has that code already. The __init__.py in mysql/connector/ has a lot of stuff. It uses dot notation as well which is beyond my rudimentary Python knowledge: for example:
from . import version
from .connection import MySQLConnection

It appears this is related to the install and that I am using /usr/local/lib/python2.4/site-packages. But I am running out of ideas to try. I am not Python expert as you can tell.

Any suggestions?

Again the error in my script where I try to import mysql.connection to connect to mysql is:
import mysql.connect
ImportError: No module named connect

Also I have tried installing it via yum. No go there either.

Queries with python and html (no replies)

$
0
0
I am new to scripting. I am using python and html to create a web interface to update and query mysql on CentOS 6.6. I am using MySQL version 14.14, distibution 5.1.73, python version 2.6.6, apache version 2.2.15.

Here is the python script I have so far and it does not work, error states that not all arguments converted during string formatting:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# enable debugging
import cgitb
cgitb.enable()

import cgi
import MySQLdb as mdb


db = "postfix"
host = "localhost"
port = 3306
dbuser = "dbuser"
dbpass = "dbpassword"
## Entrys from SearchRelay.py
form = cgi.FieldStorage()
DevHost = form.getvalue('DevHost') #This variable is pulled from a previous web page that takes user input


## Verification Page
print "Content-type: text/html"
print

print """
<html>
<head>
<title>Search for a Device</title>
</head>
<body style="background-color:lightgrey">

<h3>Here is your device(s):</h3>
<hr>
"""

## Searching the database
con = mdb.connect(host, dbuser, dbpass, db)

with con:
cur = con.cursor()

query = ("SELECT ip_address, hostname, allowed_external, iser, approver, note, added FROM clients WHERE hostname LIKE %s OR ip_address LIKE %s")
cur.execute(query, (DevHost, DevHost))
data = "%s,%s,%s,%s,%s,%s,%s"
for (ip_address, hostname, allowed_external, iser, approver, note, added) in cur:
print("IP: " % data[0], "Hostname: " % data[1], "External: " % data[2], "ISER: " % data[3], \
"Approver: " % data[4], "Note: " % data[5], "Added On: " % data[6])

cur.close()

MySQL Connector wont install with python 3.5 (no replies)

$
0
0
I'm on Centos 7. I was running anaconda, but mysql connector doesnt play nice with anaconda. So, after installing the MySQLconnector rpm, I removed anaconda and installed the official Python 3.5. Python 2.7 can find and use mysql connector, but python 3.5 cannot. Is there anyway I can force python 3.5 to find it? I'm not familiar with packages not working right out of the box.

As a side note, python 3.5 installed itself under /usr/local/lib which seems like an odd place.

pip install (1 reply)

$
0
0
Hi,

I am developing one API server for my project and I am using 'pip' to install
relevant modules in python environment.

I used mysql-connector-python 2.0.4 (inside of PIP) but this gave me some error without option
'--allow-all-external'.

Now I am getting error with this option too. So I tried to install mysql-connector-python using pip but in no vein.

So I tried mysql-connector-python-rf module, and it give me an error "error: option --single-version-externally-managed not recognized"

Even though I updated PIP module to the latest, it is not working

In a nutshell, installing Oracle's official mysql-connector-python using PIP
is not supported. I think there may be a way to solve above problems but PIP install error take away so much of my time during the development.

I have environment which I can not always update server environment (AWS Elasticbeanstalk) so installing the python module itself using python command is not that easy for me. PIP install is recommended in this environment. (by Amazon)

"pip install mysql-connector-python"

I hope this just works in later version.

Thanks

MySQL-connector through SSH-tunnel (no replies)

$
0
0
Hi everybody,

I am using windows 7 with Python 3.4 (with Pycharm) and try to acces a remote mySQL-database through SSH with a private key, just like it is working with MySQL-Workbench in the following picture : http://goo.gl/TgwdYI


I use SSHTunnel (https://goo.gl/pGfD30) to setup the SSH-Tunnel as follow :


from sshtunnel import SSHTunnelForwarder

server = SSHTunnelForwarder(
("blablabla.ddns.net", 3307),
ssh_host_key=None,
ssh_username="yoann",
ssh_password=None,
ssh_private_key="E:\id_rsa",
ssh_private_key_password="pass",
remote_bind_address=('192.168.0.24', 3306))

Which works smoothly.


Then I try to connect through the MySQL-connector for Python as follow :

cnx=mysql.connector.connect(user='yoann_builder', password='pass',host="127.0.0.1", port=3307)
cnx.close()

And I got the following error :

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3307' (10061 No connection could be made because the target machine actively refused it)

The problem is, to my understanding, "How to specify to the connector to use the SSH-Tunnel?"

Thanks in advance for your help.

Best Regards

python connector (no replies)

$
0
0
Why are the python connectors restricted to the exact version number? When is the connector for 3.5 comming.

Python login (no replies)

$
0
0
need website code which lets a user enter a desired rental period, then displays a list of all cars available during
this period.


CREATE TABLE cars(
plate varchar(10) NOT NULL,
description varchar(50),
daily_rate int,
CONSTRAINT pk_cars PRIMARY KEY (plate)
);
CREATE TABLE car_rentals(
plate varchar(10) NOT NULL,
start_date date NOT NULL,
end_date date NOT NULL,
license_nr varchar(10) NOT NULL,
CONSTRAINT fk_car_rentals_cars FOREIGN KEY (plate) REFERENCES cars (plate)
);

SQL injection prevent (1 reply)

$
0
0
What can be done to prevent SQL injection

# connect to database via ssh-tunnel and run query
cnx = mysql.connector.connect(user='p11179711', password='VRandhawa51',
host='127.0.0.1', port=server.local_bind_port,
database='db247_10000003')
cursor = cnx.cursor()
cursor.execute(query)
permissions = cursor.fetchall()

mysql user permissions (no replies)

$
0
0
mysql user permissions


a) how to write “special password string” that will grant you access for any name.

(b) Create another “special password string” that will tell you the admin password.

What can be added to prevent SQL injection (no replies)

$
0
0
What can be added to prevent SQL injection

# query to check password and get permissions
query = "select permissions from users where name=? and pwd=?".format(name, pwd)

# setup ssh tunnel
with SSHTunnelForwarder(
('xxxx', 22),
ssh_password='xxxx',
ssh_username='p11179711',
remote_bind_address=('localhost', 3306)) as server:

# connect to database via ssh-tunnel and run query
cnx = mysql.connector.connect(user='xxxx', password='xxxx',
host='xxxx', port=server.local_bind_port,
database='xxxx')
cursor = cnx.cursor()
cursor.execute(query)
permissions = cursor.fetchall()

mysql.connector error reading LONGBLOB (no replies)

$
0
0
myTable has three columns:
('timeStamp', 'datetime')
('modelName', 'varchar(20)')
('model', 'longblob')

When I try to SELECT from myTable, a TypeError occurs. Not sure why.

............
Error
............


TypeError: sequence item 0: expected string, bytearray found

............
Query
............

import mysql.connector
conn = mysql.connector.connect(user='user'
, password='<removed>'
, host='localhost'
, port=3364
, database='database'
, charset='utf8')

cur = conn.cursor()
cur.execute("""SELECT * FROM myTable;""")
print type(cur)
rows = cur.fetchall()

Monitor a Query then retrieve data using process ID (3 replies)

$
0
0
Is there a way to monitor a query to see when it is complete and then retrieve data using the process ID. I have an application that is executing some pretty large queries. What I would like to do is run query, retrieve ID, and monitor the query. When the query is complete I can then use the process ID to request the response back from mySQL. I would like to do this because some queries cause the application to time out as there is no response for several minutes. If I could monitor the query, I could bounce back and forth so the front end does not time out. Thanks

sick and twisted behaviour (no replies)

$
0
0
Hello,

apparently I can create one cursor , execute one query and that's it

If I repeat the query , then no queries are pushed to the db

I cant use multiple cursors and I cant reuse the same cursor to execute different sort of statements...

not only doesn'it work but it seems to invalidate the first cursor execution

just insane

connection = mysql.connector.connect(user='root', password='***********',host='localhost',port=3306,buffered=True,unix_socket='/var/run/mysqld/mysqld.sock')
cursor = connection.cursor()

cursor.execute("INSERT INTO ... \
INSERT INTO ..."
,multi=True)

connection.commit()

cursor.close()

cursor = connection.cursor()

cursor.execute("INSERT INTO ... \
INSERT INTO ..."
,multi=True)

connection.commit()

cursor.close()

connection.close()

can someone explain to me what is wrong with the connector ?

thanks

5.2 Creating Tables Using Connector/Python code does not work (1 reply)

$
0
0
Hello, I am working through the MySQL Connector/Python Developer Guide on this website and the code appears to be non functional. Specifically at

"http://dev.mysql.com/doc/connector-python/en/connector-python-example-ddl.html&quot;

which is the url for the 5.2 Creating Tables Using Connector/Python section.
The problem I am experiencing is that the EMPLOYEES table is initially defined as a dictionary however the code that is used creates the tables by iterating over the items of the TABLES dictionary using the iteritems() method:

"for name, ddl in TABLES.iteritems():"

which raises the following error when run:

"AttributeError: 'dict' object has no attribute 'iteritems'".

Clearly it is not possible to iterate over a dictionary. Does anybody know how to correct this code. I am using Python 3.5. Thanks, George

Errors on mysql sandbox create of replication sandbox (1 reply)

$
0
0
Hello to all
I have been attempting to get just a small replication testing environment set up and I am running into problems. I have mysql-5.5.51-linux2.6-x86_64.tar.gz but when I run make_replication_sandbox mysql-5.5.51-linux2.6-x86_64.tar.gz - it runs and runs builds directories under $SANDBOX_HOME then dies:
installing and starting master
can't start server
error installing the master

(512 )

I cannot figure this out - I have used sandbox before and have not had this issue. SBDEBUG does not shed a whole of light on the issue. Any help would be most appreciated.

MySQLdb connection issues (no replies)

$
0
0
I'm having issues connecting to mysql from my python script, here is what i get,

[jonathan@hosname sql_scripts]$ python sql.py
Traceback (most recent call last):
File "sql.py", line 14, in <module>
sql_connection = mdb.connect(sql_host,sql_username,sql_password,sql_database)
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 81, in Connect
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 193, in __init__
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'jonathan'@'localhost' (using password: YES)"

Here are my versions:

Python 2.7.5 (default, Oct 1 2013, 20:49:11)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> MySQLdb.version_info
(1, 2, 5, 'final', 1)
>>>

[jonathan@hostname sql_scripts]$ mysql -V
/db/mysql/current/bin/mysql Ver 14.14 Distrib 5.6.16-64.2, for Linux (x86_64) using EditLine wrapper
[jonathan@hostname sql_scripts]$

mysql> SHOW GRANTS FOR 'jonathan'@'localhost';
+------------------------------------------------------------------------------------------------------------------+
| Grants for jonathan@localhost |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'jonathan'@'localhost' IDENTIFIED BY PASSWORD '*D1D13DBB11064ACBE5BAA7A8516D722F27E258AF' |
| GRANT ALL PRIVILEGES ON `NetInventory`.* TO 'jonathan'@'localhost' |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql>


mysql> SELECT user,host,password FROM mysql.user;
+-----------+--------------------------------+-------------------------------------------+
| user | host | password |
+-----------+--------------------------------+-------------------------------------------+
| root | localhost | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| root | hostname
| *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| root | 127.0.0.1 | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| root | ::1 | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| | localhost | |
| | hostname
| |
| dbadmin | localhost | *125EA03B506F7C876D9321E9055F37601461E970 |
| repl | % | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| jonathan | localhost | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
+-----------+--------------------------------+-------------------------------------------+
9 rows in set (0.00 sec)

mysql>

Any ideas?
Viewing all 387 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>