Use this tag for questions about the MySQL-Python database connector library (MySQLdb). Do not use this tag for questions about MySQL Connector/Python (use the [mysql-connector-python] tag instead).
0
votes
0answers
8 views
Python MYSql.connector will not insert data
I am trying to insert some data into a a database I am making and it will not insert. I literally have used the same insert method on other code and it still seems to work, however this one refuses ...
0
votes
1answer
16 views
Python MySQLdb TypeError(“not all arguments converted during string formatting”)
I know this is a popular topic but I searched the various answers and didn't see a clear answer to my issue. I have a function that I want to use to insert records into my NDBC database that is ...
0
votes
0answers
16 views
SQLAlchemy reports “Invalid utf8mb4 character string” for BINARY column
Assuming this MySQL table schema:
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uuid` binary(16) NOT NULL,
`email` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
...
0
votes
0answers
12 views
Error “Not all arguments converted during string formatting” in flask project
I have created a signup in flask with wtforms using the following code:
from flask import Flask,render_template,request,url_for,flash,session
from flask_session import Session
from dbconnect import ...
0
votes
2answers
33 views
How to execute the mysql statement in my python code?
I can run the following sql in my my-sql client and return the right result :
mysql> select cj.name job_name , cb.build_result build_result, count(*) total , GROUP_CONCAT(cb.id) id_list
...
1
vote
2answers
28 views
Python and MySQL UPDATE
Everything is working as it should for the ping tool but MySQL updates are failing.
It should pull the ip address it is currently doing and update it in the MYSQL.
import MySQLdb
db = ...
1
vote
1answer
38 views
Python MySQLdb - Getting a ValueError
Trying to import a list into MySQL through Python with MySQLdb...code below.
I get a ValueError when I run it -
query = query % tuple([db.literal(item) for item in args])
ValueError: unsupported ...
0
votes
2answers
51 views
how to insert values into mysql table from another bigquery response
My Python program connects to BigQuery and fetching data which I want to insert into a MySQL table. It's successfully fetching the results from BigQuery. It's also successfully connecting to MySQL ...
1
vote
2answers
29 views
Python outputting MySQL data returned from method
This is a first of a kind problem for me, and really not sure how to troubleshoot it.
I have a simple Python/MySQL project I'm working on for fun. I have a separate class, with it's own methods, to ...
1
vote
0answers
42 views
Is it possible to configure PyCharm to support MySQLdb placeholder syntax? [duplicate]
When I have "Resolve unqualified references" enabled and dialect set to MySQL, PyCharm attempts to parse statements that look like SQL statements. This works for simple statements, but PyCharm is ...
0
votes
1answer
52 views
I am not able to connect my python program using mysqldb with lampp server [duplicate]
I am able to connect my Python program with lampp server using mysqldb as host="localhost" but as soon as change host="myIPaddress" it is showing errors for sql queries.
This is working fine:
...
1
vote
1answer
27 views
pytest mysql db fixture: cannot create database
I'm trying to use mysql from pytest-dbfixtures. I have a test file with example from documentation:
def test_using_mysql(mysql):
mysql.query("SELECT CURRENT_USER()")
and when I run it via $ ...
1
vote
1answer
25 views
MySQL, fetchone and LIMIT
Here is a sample of python code:
query = "SELECT * FROM users WHERE id = 17"
cursor.execute(query)
row = cursor.fetchone()
In this example, the query is meant to return at most a single row; but ...
0
votes
1answer
16 views
How can I use INSERT data WHERE correctly in python (MySQLdb import)?
I am trying this code and keeps giving me errors.
I wanted the 3rd for cicle to add the role in the same line as the name in the table, so I was thinking using the WHERE to find the name, but ...
0
votes
1answer
41 views
How to use MySQLdb to run Explain queries?
as the title says
When I use MySQLdb to run an explain statement against the MySQL server,the return result is an integer,e.g. 1
How can i get the the explain results like this ?
...
0
votes
3answers
43 views
Python querying mysql iteratively
I have a list of column names that I want to pull from a mysql database. It is good practice to loop through it and query each time?
When I do this, sometimes/randomly it seems to hang; when I ...
0
votes
1answer
16 views
Installing Python with MySQL connector on Red Hat
I'm having trouble making MySQL connector work with Python.
I started with a fresh new installation of Red Hat 6.4.
The system already had Python 2.6.6 installed by default, I need however version ...
0
votes
0answers
36 views
different results of mysql in python and mysql console
I want to show the createtable time of mysql table:
I run this in mysql console
MariaDB [Restaurant]> select CREATE_TIME from information_schema.tables where table_name = 'mytalbe';
...
0
votes
0answers
16 views
Error while connecting to mysql database from godaddy server
I am trying to connect a MySQL database from a GoDaddy server by the below code
import pymysql
connection = pymysql.connect('166.62.8.6 ', 'weatherdata', '****', 'weatherdata')
It is raising an ...
0
votes
0answers
14 views
Python: replication of local mysql db on remote mysql db
I developed a python program that must stored datas into a mysql db.
I would that this db, is on remote server but on the computer, where the program runs, sometimes I don't have internet connection ...
0
votes
1answer
13 views
Python rowcount returning negative 1
Please can someone help i cant believe I am not getting this right. I am trying to count the number of rows that I have in a mysql db. The correct number is 7, however everytime I execute the ...
0
votes
1answer
17 views
Why can my Python MySQLdb script see, but not make live changes to, my database?
I am working with a customized Django installation, although the issue I am dealing with is from a command line tool intended to update the database. The tool reads the database as intended and ...
0
votes
0answers
22 views
MySQLdb installation Stuck
I'm using Ubuntu Server 14.04 and i need to install MySQLdb..
Firstly, I installing MySQLdb by downloading MySQLdb installer and doing these steps :
$ gunzip MySQL-python-1.2.2.tar.gz
$ tar -xvf ...
1
vote
0answers
31 views
SAWarning: Exception attempting to detect unicode returns: ProgrammingError AND SAWarning: Unknown schema content
When inserting a table into Memsql from Python using pandas I receive the following error/warning. I am using PyMySQL as the connector/engine.
The table does not contain any strings and upon ...
0
votes
0answers
8 views
Issues updating into MySQL from python [duplicate]
This is how I'm expecting to do an update in Python
sql = """UPDATE task_history SET %s = %s WHERE tdate = %s)"""
cur.execute(sql, (sqlgroup,total,timeStamp))
However I keep getting an error in SQL ...
1
vote
1answer
24 views
How to make a simple script in MYSQL Workbench to execute a query and export results into a CSV
I'm really new at coding.
I'm just trying to figure out how to make a simple script for Mysql Workbench that it just runs a given query, and then exports the results into a CSV.
I know this works ...
-1
votes
0answers
16 views
IntegrityError: (1215, 'Cannot add foreign key constraint')
I know there are similar questions, but looking at them I didn't solve my problem:
I created 2 tables, one city and one region. I didn't include any relationship while creating them, so I'd like to ...
0
votes
1answer
20 views
Cannot Import MySQLdb in PyCharm, runs fine in terminal.
I have problems trying to run a script which imports MySQLdb within PyCharm.
Running the script from terminal works just fine while running within PyCharm fails with
ImportError: No module named ...
-1
votes
0answers
27 views
Python MySQLdb performance
I am running a select statement with python MySQLdb with a result set of nearly 100M rows. The query itself just takes a few minutes(judge from 'show process list' on mysql server), but it takes more ...
0
votes
0answers
22 views
MySQLdb query hanging
I'm using the MySQLdb package in python to connect to a local database.
I connect to the database as follows:
db = MySQLdb.connect(host=os.environ.get("DEVELOPMENT_SQL_SERVER"), ...
-1
votes
1answer
15 views
Access to MySql server-From any computer?
I am using mysql.connector package.
I want to make sure it is possible to remotely connect to a database from any IP (especially from computers that MySql is not installed in) via basic authentication ...
0
votes
2answers
20 views
Python select with _mysql module without an error
I need to use _mysql, but i don't know how to get all the output of my selection without an error.
db = sql.connect(host=host,user=user,passwd=pw,db=dbName)
db.query(query)
rows = db.use_result()
...
0
votes
1answer
23 views
Accessing global cursor from within function
This works okay (some code ommited for brevity):
# main.py
cursor = db.cursor()
cursor.execute('foo')
As does this:
# other.py
def do_something(script, cursor):
cursor.execute(script)
# main.py
...
1
vote
0answers
24 views
MySQLdb configuration error while running Python manage.py makemigrations on Windows
I am setting up a web server for Python on Windows. While configuring settings.py, I changed the database to
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
...
0
votes
1answer
20 views
How to get row ids when using LOAD LOCAL DATA INFILE?
I have MySQL database with table into which I insert from multiple files using
LOAD DATA LOCAL INFILE ... statement. I have PRIMARY KEY ID set to auto_increment. The problem is, when I want to update ...
2
votes
2answers
58 views
how to create a SQL database from a csv file in Python
I need to load in a large dataset (20gb for now but will be 100 gb in the future) from a csv file. I am using the MySQLdb module in python (PyCharm). I also need to only select some certain columns. ...
0
votes
1answer
12 views
Error Executing : mysqlfabric sharding add_table 1 employees.employees emp_no
When I execute the following command for creating shard :
mysqlfabric sharding add_table 1 employees.employees emp_no
I get the following error:
DatabaseError: Command (INSERT INTO ...
0
votes
1answer
14 views
use multiprocessing to query in same mysqldb connnect , block?
abort MySQLdb.
I know many process not use same connect, Because this will be a problem .
BUT, run the under code , mysql request is block , then many process start to query sql at the same time , ...
-1
votes
0answers
38 views
Different Result Via Python MySQL Connection Than MySQL Command Line
For speed I normally develop my MySQL queries using the MySQL command line before incorporating them into our main application written in Python. However late yesterday I came up with an issue I am ...
1
vote
2answers
23 views
MySQLdb error local variable referenced before assignment (different than usual)
I am attempting to add some data to MySQL database via a loop that iterates through the API that returns a JSON file. I am using Python and MySQLdb module.
For some reason I am getting the infamous ...
1
vote
1answer
23 views
Mysqldb and Python KeyError Handling
I am attempting to add multiple values to MySQL table, here's the code:
Try:
cursor.execute("INSERT INTO companies_and_charges_tmp (etags, company_id, created, delivered, satisfied, status, ...
1
vote
1answer
28 views
ValueError(“unsupported format character 'A' (0x41) at index 185”,)
I am trying to execute a query which lists certain values of my db that match the inputs of my html search form. I want it to do the search even if some of the form inputs are empty inputs.I am using ...
0
votes
0answers
34 views
Python loop Google Places returns duplicate results
So, I am running a places api textsearch loop using the following list:
In [6]: companies
Out[6]:
['MARINE AND GENERAL MUTUAL LIFE ASSURANCE SOCIETY',
'KENTSTONE PROPERTIES LIMITED',
'ASHFORD CATTLE ...
-1
votes
2answers
56 views
Python: adding named tuples to MySQL in a for loop
So I have the following namedtuple, containing multiple items:
[item(company='MARINE AND GENERAL MUTUAL LIFE ASSURANCE SOCIETY', google_name='no results', place_id='no results', formatted_address='no ...
0
votes
0answers
16 views
How to control log level when using MySQLdb
I am using MySQLdb in python. And I found MySQLdb can print some log to my console, mixed with other logs printed by me. So, could I offer a logging.conf file, and specifiy a logger for MySQLdb, and ...
0
votes
1answer
19 views
Installing MySQLdb for python2.7
I have various versions of python (python2.4 and python2.7) installed on the CentOS machine. I installed MySQL-python, but I can only import the MySQLdb module on python2.4 but not python2.7
root# ...
1
vote
1answer
32 views
Python MySQLdb Query Returns “None”
I'm running the following code with web.py to get mysql data and print it out on a webpage. For some reason, when I query the webpage, I get just the word "None". Any idea what the problem is? There ...
-1
votes
2answers
19 views
XML to python using beautifulsoup and different XML types
I'm working with some xml and my job now is to get the xml and get some data to SQL db..
The thing is, I have to types of xml docs like:
I have "cpc-definition-A.xml":
...
0
votes
1answer
90 views
Can't install mysql-python version 1.2.5 in Windows
I have mysql-python v1.2.4 installed just fine on my machine (Windows 8). I am using Python 2.7. I always got this below error every time I try to upgrade to v1.2.5.
...
0
votes
1answer
79 views
Python3.5 Refuse to Work with MySQL Connector
I've read a few questions on here that people are having the same situation as me but no matter what method I tried, it just wouldn't work!
According to MySQL documentation, ...