Closed HarbingerOfFire closed 2 weeks ago
Can you provide a video reproducing this issue? It can help to see how it runs on your system and maybe can help to get a fix for this.
you should be able to view it here
Only happens when I run auto_commit:
Traceback (most recent call last): File "d:\github\bivittatusDB\src\ex_auto_commit.py", line 2, in <module> import BivittatusDB as bdb File "d:\github\bivittatusDB\src\BivittatusDB.py", line 2, in <module> from BDB_tb import * File "d:\github\bivittatusDB\src\BDB_tb.py", line 1, in <module> import datetime, BDB_metadata File "d:\github\bivittatusDB\src\BDB_metadata.py", line 4, in <module> from BDB_io import DBio_lib File "d:\github\bivittatusDB\src\BDB_io.py", line 4, in <module> io_lib = ctypes.CDLL("./lib_bdb.so") ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: Could not find module 'D:\github\bivittatusDB\lib_bdb.so' (or one of its dependencies). Try using the full path with constructor syntax.
Are you running from inside the src folder?
Sorry about those typos...
Yes, I was running in the src folder, now the question is why it doesn't work for me now.
it looks like the code isn't run from the folder though, since it's looking for D:\github\bivittatusDB\lib_bdb.so
when it should be looking for D:\github\bivittatusDB\src\lib_bdb.so
What?, but in my computer appears in this path
yeah, but what directory is your ide located in?
C:\Users\dev\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Visual Studio Code
I meant like what folder is it opened to. Like:
interesting, right folder, but the file isn't there?
If I take out the lib_bdb.so file it doesn't give error, but if it's inside src it jumps
in the bdb_io.py
file add the following lines before loading the c-lib.
from pathlib import Path
print(Path("mydir/myfile.txt").absolute())
D:\github\bivittatusDB\mydir\myfile.txt
Yeah, the code seems to be running outside of the src directory for you. That is weird
Which python version are you running? Maybe it's the interpreter version of python (to be ruled out)
3.12.2 I don't know if this is an issue with a code as much as the ide though
@HarbingerOfFire I have made a test, using the next code:
import os
current_dir = os.path.dirname(os.path.realpath(__file__))
print("This is the current dir:",current_dir)
And the output it's:
This is the current dir: D:\github\bivittatusDB\src
When this file it's out of src or inside in the same directory the output is the same
Yeah, that's telling you the path of the file you're running. Try replacing __file__
with lib_bdb.so
and is probably going to give This is the current dir: D:\github\bivittatusDB
I'm going to go ahead and close this as I'm making a lot of updates for the file-per-table version which should hopefully fix the initial error. Hopefully when you sync your changes it will solve your errors as well.
@HarbingerOfFire I have a very strange question. In VS in the terminal the output is: This is the current directory: D:\github\bivittatusDB
But using CMD running the code the output is:
This is the current directory: D:\github\bivittatusDBDB\src
Is it a problem with VS or what is going on?
CMD:
VS:
Notice the difference in the prompt. CMD has you in the src/ directory but in VS you are in it's parent folder. Just to make sure, this is Visual Studio Code and not Visual Studio \
@ScriptSlayer0 If you are in VSCode, you can use ctrl+k, ctrl+o then you can select the /src directory. Then run the test.py code again
Actually, the last update should fix your problem. Let me know if you still experience the error
I have improved the code at the beginning I was doing quite a lot of testing to get it right. Code:
import os
def find_path(file_name):
for root, dirs, files in os.walk('/'):
if file_name in files:
return os.path.join(root, file_name)
file_path = find_path('lib_bdb.so')
if file_path:
print(f"The file 'lib_bdb.so' is located in: {file_path}")
else:
print("File 'lib_bdb.so' was not found.")
Output:
The file 'lib_bdb.so' is located in: /github\BivitattusDatabase\lib_bdb.so
Actually, the last update should fix your problem. Let me know if you still experience the error
I already working: ex_autocommit.py, ex_use_table.py
Using ex_update.py (output): Couldn't make directory: File exists
Noted, that should be from the fact that you haven't deleted the old database when changing example files and most of the example files initialize the same database. Since you can't reinitialize the same database, this throws up an error. I'll add a fix later today for a drop clause that will be noted for best practices.
Fix made. Let me know if error continues
When I generate a new DB with autocommit, then I executing the ex_use_table.py it throws me:
No data to show.
So strange...
That means the table is empty. add a few rows and then print it.
I think ex_add_rows.py
it's bugged, after adding rows to the table throws when you are using the same table like a blank table.
ex_add_rows.py
doesn't commit the changes in any way. They are just staged in memory. Either turn on autocommit (ex_auto_commit.py
) or save the change (ex_save.py
) and retry.
I tested the example files and they all work as expected. I pushed this to release as version 4.1.0. I'm going to go ahead and lock this issue. If you find anything else you can always open a new issue.
When I start using auto commit, I can add two rows to a table, but during the second run, it removes the data from the metadata segment of the database file. I can't figure out why this is happening.
To Reproduce In the example file contained in the src directory, add the line
tb1@bdb.ON
to turn on auto commit, and then run that. It doesn't error with a normal traceback, but windows says it exits with code -1073740791. You'll also notice that it doesn't run the print table step.Screenshots If you can read this, you'll see the metadata table here is intact. Here is the same data after the adding of the second table. That metadata is corrupted: