0

I want use python reliability library from reliability.readthedocs.io but with data i had on mysql. Already connected to mysql using PyMysql but i don't know how to use/convert the data to the library code. Here the code i tried to use,

from reliability.Fitters import Fit_Everything
import math
import pymysql
  
def mysqlconnect():
    # To connect MySQL database
    conn = pymysql.connect(
        host='localhost',
        user='root', 
        password = "",
        db='baru',
        )
      
    cur = conn.cursor()
      
    # Select query
    cur.execute("select * from cobadata")
    rows = cur.fetchall()
      


   # To close the connection
    conn.close()
  
# Driver Code
if __name__ == "__main__" :
    mysqlconnect()

data = rows
results = Fit_Everything(failures=data, show_histogram_plot=False, show_probability_plot=False, show_PP_plot=False, show_best_distribution_probability_plot=False)
output = Fit_Everything(data)
#fit all the models
print('The best fitting distribution was', results.best_distribution_name, 'which had parameters', results.best_distribution.parameters)

It given an error like this NameError: name 'rows' is not defined. How to solve this? Thanks in advance.

rifrxin
  • 1
  • 2
  • i updated the code i tried to use, can you review it and help me? TIA @Luuk – rifrxin Jun 05 '22 at 07:02
  • Does this answer your question? [NameError: name '...' is not defined](https://stackoverflow.com/questions/43760927/nameerror-name-row-is-not-defined) – Luuk Jun 05 '22 at 09:01

0 Answers0