Skip to content

sqlite-bro broken in python-3.13.0b1 #1337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stonebig opened this issue May 9, 2024 · 5 comments
Closed

sqlite-bro broken in python-3.13.0b1 #1337

stonebig opened this issue May 9, 2024 · 5 comments

Comments

@stonebig
Copy link
Contributor

stonebig commented May 9, 2024

the example of custom fonction (py_sin) doesn't work.

but this manual program works:

import sqlite3
def _customFun(fstring, dept):
    result = 'Welcome ' + fstring + ' your dept is ' + dept
    return result


connection = sqlite3.connect(":memory:")
cursor = connection.cursor()
connection.create_function("ROHACK", 2, _customFun)
sql="CREATE TABLE student (First_Name, Department, Student_ID);"
cursor.execute(sql)
sql='INSERT INTO student values("Toto","LLM class", 1)'
cursor.execute(sql)

sqlQuery = "select ROHACK(First_Name,Department) from student where Student_ID = 1"
cursor.execute(sqlQuery)
print(*cursor.fetchone())

cursor.close()
connection.close()
@stonebig
Copy link
Contributor Author

stonebig commented May 10, 2024

it seems a bug, as eval('py_hello') breaks

@stonebig
Copy link
Contributor Author

stonebig commented May 11, 2024

issue raised, to see if it's normal or a bug: python/cpython#118938

this works on Python-3.12 and before, fails on 3.13.0b1:

a="""def py_helloa():
    "hello world"
    return ("Hello, a World !");""";

exec(a, globals(), locals());
ae=eval('py_helloa');
print(ae())

def test():
    b="""def py_hellob():
    "hello world"
    return ("Hello, b World !");""";
    exec(b, globals(), locals());
    be=eval('py_hellob');
    print(be())
test()

@stonebig
Copy link
Contributor Author

so a Python-3.13 compatible code is, beause of PEP 667, this way:

d={}

a="""def py_helloa():
    "hello world"
    return ("Hello, a World !");""";

exec(a, globals(), locals());
ae=eval('py_helloa');
print(ae())

def test():
    b="""def py_hellob():
    "hello world"
    return ("Hello, b World !");""";
    exec(b, globals(), d);
    be=eval('py_hellob', d);
    print(be())
test()

@stonebig
Copy link
Contributor Author

stonebig commented May 11, 2024

sqlite_bro-3.13.0 pushed on Github, apparently compatible with Python-3.12 and 3.13

@stonebig
Copy link
Contributor Author

Baresql github shall be fixed too, now.
Baresql as found its use case with python-in-excel, till duckdb gets included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant