I am trying to get data from JSON. Thereafter, I want to insert it into a new table. In my class DB I have 2 methods: create_connect
and add_records
. In create_connect
method I had created variable 'cur' - cursor. Now, I want to use this variable in add_records
method. How I can do that?
I tried the following code but it throws error:
def create_connect(self, dbname):
cur = con.cursor()
def add_records(self, id, date, open_p, close_p, high_p, low_p, dbname):
cur.execute(sql_insert_query, recordTuple)
NameError: name 'cur' is not defined