pymysql

pymysql retrievingdata in batches

pymysql retrievingdata in batches Question: i am using pymysql to interact with an sql db, here is the code: query = “SELECT * FROM my_table” c = db.cursor(pymysql.cursors.DictCursor) c.execute(query) c.fetchall() now i am doing this for a database of 3000 enteries which isn’t alot, i plan to use this on a database with 15 million …

Total answers: 2

How to insert data to django database from views.py file?

How to insert data to django database from views.py file? Question: How can I insert data to my django database from a function in the views,py file? Is python manage.py shell the only way to insert? For more explanations I’m using: python 3.4 django 1.8.2 PyMySQL For example: models.py: from django.db import models class Publisher(models.Model): …

Total answers: 4

No module named 'pymysql'

No module named 'pymysql' Question: I’m trying to use PyMySQL on Ubuntu. I’ve installed pymysql using both pip and pip3 but every time I use import pymysql, it returns ImportError: No module named ‘pymysql’ I’m using Ubuntu 15.10 64-bit and Python 3.5. The same .py works on Windows with Python 3.5, but not on Ubuntu. …

Total answers: 20

Can I use pymysql.connect() with "with" statement?

Can I use pymysql.connect() with "with" statement? Question: The following is listed as example in pymysql: conn = pymysql.connect(…) with conn.cursor() as cursor: cursor.execute(…) … conn.close() Can I use the following instead, or will this leave a lingering connection? (it executes successfully) import pymysql with pymysql.connect(…) as cursor: cursor.execute(‘show tables’) (python 3, latest pymysql) Asked …

Total answers: 4

Using Python to access SQL with a variable column name

Using Python to access SQL with a variable column name Question: I’m to link my code to a MySQL database using pymysql. In general everything has gone smoothly but I’m having difficulty with the following function to find the minimum of a variable column. def findmin(column): cur = db.cursor() sql = "SELECT MIN(%s) FROM table" …

Total answers: 1

Pymysql Insert Into not working

Pymysql Insert Into not working Question: I’m running this from PyDev in Eclipse… import pymysql conn = pymysql.connect(host=’localhost’, port=3306, user=’userid’, passwd=’password’, db=’fan’) cur = conn.cursor() print “writing to db” cur.execute(“INSERT INTO cbs_transactions(leagueID) VALUES (‘test val’)”) print “wrote to db” The result is, at the top of the Console it says C:…test.py, and in the Console: …

Total answers: 3

What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?

What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment? Question: I just solved some problems in my Django 1.3 app by using PyMySQL instead of MySQLdb. I followed this tutorial on how to make the switch: http://web-eng-help.blogspot.com/2010/09/install-mysql-5-for-python-26-and.html Now I want to know what PyMySQL actually is and how it …

Total answers: 5