Skip to content
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

bdb.execute(sql) fails but bdb.sql_execute(sql) succeeds on SELECT #484

Open
fsaad opened this issue Oct 13, 2016 · 4 comments
Open

bdb.execute(sql) fails but bdb.sql_execute(sql) succeeds on SELECT #484

fsaad opened this issue Oct 13, 2016 · 4 comments

Comments

@fsaad
Copy link
Collaborator

fsaad commented Oct 13, 2016

    bdb = bayeslite.bayesdb_open('resources/gapminder.bdb')
    pairwise = query(bdb, 'SELECT name0, name1 FROM dependence;')
    for row in pairwise.values[:1]:
        name0, name1 = row
        sql = '''
            SELECT %s, %s FROM %s
        ''' % (
            sqlite3_quote_name(name0),
            sqlite3_quote_name(name1),
            sqlite3_quote_name('gapminder_t'))
        print sql
        frame = bdb.sql_execute(sql).fetchall()
        print frame

OK, but replacing the line

        frame = bdb.execute(sql).fetchall()

returns

AssertionError: Invalid select table: u'gapminder_t'
@fsaad fsaad changed the title bdb.execute(sql) fails but bdb.sql_execute(sql) succeeds bdb.execute(sql) fails but bdb.sql_execute(sql) succeeds on SELECT Oct 13, 2016
@riastradh-probcomp
Copy link
Contributor

Can you share gapminder.bdb, or the results of the initial SELECT, or a SQL trace from this program?

@fsaad
Copy link
Collaborator Author

fsaad commented Jan 18, 2017

Saving another incarnation of this error using COUNT(*) for future reference, where bdb.execute complains

E           AssertionError: Invalid select table: u't'

but bdb.sql_execute is fine

                    qt = sqlite3_quote_name(table)
                    qc = sqlite3_quote_name(cmd.name)
                    cursor = bdb.execute(
                        'SELECT COUNT(*) FROM %s WHERE %s IS NOT NULL' %
                        (qt, qc))

The data is from test_csv.csv_data and qc is height.

@riastradh-probcomp
Copy link
Contributor

riastradh-probcomp commented Jan 18, 2017 via email

@riastradh-probcomp
Copy link
Contributor

What is query here?

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

2 participants