Python Forum
ssh + mysql connection python 3.4.3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ssh + mysql connection python 3.4.3
#5
This is the first few lines of what I have for remote access to database.

# working live JP 20170312
# boilergraph.py to display boiler temperatures 20170502
import MySQLdb
import time
import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.animation as animation
from matplotlib import style
from time import sleep

style.use('ggplot')
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)

dt = []
a = []
b = []
ca = []
d = []
dtf=[]
dtg=[]
i=0
lr=0

def read_from_db():
    del dt[:]
    del a[:]
    del b[:]
    del ca[:]
    del d[:]
    del dtf[:]
    del dtg[:]
    global lr
    conn = MySQLdb.connect("192.168.1.162","user1","passuser1","jp1")
    c = conn.cursor()
    c.execute('SELECT * FROM boiltbl WHERE dt >= now() - interval 2 hour')
Just ignore the poor form and extra stuff.  This works great, although, as mentioned took some effort to get the users and passwords set up to mySQL's liking.  

Don't know what pymysql is but to my knowledge all the mySQL derivatives work the same.
Reply


Messages In This Thread
ssh + mysql connection python 3.4.3 - by desudesu - May-19-2017, 11:24 AM
RE: ssh + mysql connection python 3.4.3 - by jogl - May-19-2017, 04:54 PM
RE: ssh + mysql connection python 3.4.3 - by nilamo - May-19-2017, 10:10 PM
RE: ssh + mysql connection python 3.4.3 - by jogl - May-20-2017, 09:57 AM
RE: ssh + mysql connection python 3.4.3 - by nilamo - May-25-2017, 12:56 PM
RE: ssh + mysql connection python 3.4.3 - by nilamo - May-25-2017, 01:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issues with MySql Connection EMG2024 2 1,106 May-29-2024, 03:11 PM
Last Post: EMG2024
  I don't know what is wrong (Python and SQL connection) shereen 3 1,522 Apr-01-2024, 08:56 AM
Last Post: Pedroski55
  No Internet connection when running a Python script basil_555 8 3,706 Mar-11-2024, 11:02 AM
Last Post: snippsat
  Connection LTspice-Python with PyLTSpice bartel90 0 1,165 Feb-05-2024, 11:46 AM
Last Post: bartel90
  Virtual Env changing mysql connection string in python Fredesetes 0 1,078 Dec-20-2023, 04:06 PM
Last Post: Fredesetes
  connection python and SQL dawid294 4 1,859 Dec-12-2023, 08:22 AM
Last Post: Pedroski55
  Mysql and mysql.connector error lostintime 2 1,818 Oct-03-2023, 10:25 PM
Last Post: lostintime
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 1,525 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  Mysql error message: Lost connection to MySQL server during query tomtom 6 22,107 Feb-09-2022, 09:55 AM
Last Post: ibreeden
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 8,852 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020