c-jo / cpython

RISC OS port of the Python programming language
https://www.python.org/
Other
7 stars 3 forks source link

sqlite3 fails on python3 RISC OS #19

Open riscman opened 3 years ago

riscman commented 3 years ago

Please accept my my apologies if this is not the correct place to report a problem with RISC OS Python. Gerph suggested I post this to "issues"

The following python script runs to completion on Linux and creates a database file "test_db" in the same directory as the script.


import sqlite3
con = sqlite3.connect('test_db')
cur = con.cursor()
cur.execute("CREATE TABLE tab1 (name, phone)")
cur.execute("INSERT INTO tab1 VALUES('Bob',1234)")
con.close()
print("reached end of script")

On RISC OS Python3 the same code fails with error:-


  File "testSQL/py", line 4, in 
    cur.execute("CREATE TABLE tab1 (name, phone)")
    sqlite3.DatabaseError: file is not a database

It does create a file but it does not put it in the same directory as the python script, but in the parent directory. It also mangles the name. The created file has the parent directory name appended to it using a / separator. Eg the script file is "testSQL/py" in directory "sqlite" The new database file is not in "sqlite", but in the directory above and has a filename of "sqlite/test_db" It looks as if the unix to RISC OS file conversion algorithm is going wrong.

c-jo commented 3 years ago

Thanks for the report. It sounds like the usual filename translation thing - I will take a look!