Closed ScriptSlayer0 closed 2 months ago
Does ex_use_table.py
work now too?
Doesn't work yet, I'm working on it.
I'm experimenting with these next errors:
binascii.Error: Non-hexadecimal digit found
binascii.Error: Odd-length string
Error loading table table1 from database test: 'str' object has no attribute 'pop'
(right now)
(Only happens when I run ex_use_table.py
)
what line is throwing the error?
Line 21 BivittatusDB.py with traceback.format_exc():
Error loading table table1 from database test: 'str' object has no attribute 'pop'
Traceback (most recent call last):
File "d:\github\bivittatusDB\src\BivitattusDB\BivittatusDB.py", line 20, in load_table
return table(self.database_name, table_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\github\bivittatusDB\src\BivitattusDB\BDB_tb.py", line 13, in __init__
self.__read__()
File "d:\github\bivittatusDB\src\BivitattusDB\BDB_tb.py", line 46, in __read__
self.columns = self.data.pop(0)
^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'pop'
print the value of self.data before line 46
It thows me None
you do have a pydb file in the directory your running it from, right?
Yes
Try regenerating the file using ex_auto_commit.py
, and see if the error persists
With this change works ex_use_table.py
not ex_auto_commit.py
:
def __read__(self):
'''Read data from a file'''
try:
reader = io.HDF5Handler(self.database)
except Exception as e:
print(f"Error reading the database: {e}")
return None
try:
self.data = reader.read_table(self.table_name)
print(f"Value of self.data before processing: {self.data}") # Added print statement
# Assuming the data is returned as a JSON string, decode it
self.data = json.loads(self.data)
print(f"Value of self.data after JSON decoding: {self.data}")
except Exception as e:
print(f"Error reading the table {self.table_name}: {e}")
return None
# Check if self.data is a list
if isinstance(self.data, list):
self.columns = self.data.pop(0)
else:
print(f"Unexpected data format: {type(self.data)}")
return None
return self.data
And with this one only works auto_commit.py
:
def __read__(self):
'''Read data from a file'''
try:
reader = io.HDF5Handler(self.database)
except Exception as e:
print(f"Error reading the database: {e}")
return None
try:
self.data = reader.read_table(self.table_name)
except Exception as e:
print(f"Error reading the table {self.table_name}: {e}")
return None
self.columns = self.data.pop(0)
return self.data`
Why?. I don't really know for the moment. (All changes are made in DBD_tb.py)
use_table.py
shouldn't work with that code since the reader.read_table()
should return an already decoded form of the data. In auto_commit.py
that same code errors because it's trying to decode an already decoded object, which causes it to exit. It'll probably work for both if you remove the return None
line in the first code, but I think we still need to figure out why use_table.py
isn't properly being decoded during by the reader.
also, can I ask what system you are running on?
also, can I ask what system you are running on?
I'm running windows 11.
Ok, I'm going to go ahead and merge it, but not going to make a stable release then, and I'll work on getting everything updated with the new database system this week.
Password for test: +--+-----+ |id|name | +--+-----+ |1 |Alice| |2 |Bob | |3 |Cindy| +--+-----+
Now works