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

Cannot create table #84

Open
wayjjpku opened this issue Jul 1, 2019 · 5 comments
Open

Cannot create table #84

wayjjpku opened this issue Jul 1, 2019 · 5 comments

Comments

@wayjjpku
Copy link

wayjjpku commented Jul 1, 2019

At first, i ran the code as showed below, it's ok, but with warnings:

C:\Users\xxxx\AppData\Roaming\Python\Python36\site-packages\urllib3\connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)**


import prestodb
conn =  prestodb.dbapi.connect(
    host='172.29.XX.XXX',
    port=1000,
    user='[email protected]',
    catalog='hive',
    http_scheme='https',
    auth=prestodb.auth.BasicAuthentication(username="[email protected]",password="AAA"),

   #isolation_level=prestodb.transaction.IsolationLevel.
)
cur = conn.cursor()
cur.execute(""" select *  from  tmp_qiyejinrong.cs201901701_345""")
rows = cur.fetchall()
column_names = [desc[0] for desc in cur.description]
df = pd.DataFrame(rows, columns = column_names)

but when i run the code using create table or drop table , it comes out nothing!!!:

import prestodb

conn =  prestodb.dbapi.connect(
    host='172.29.XX.XXX',
    port=1000,
    user='[email protected]',
    catalog='hive',
    http_scheme='https',
    auth=prestodb.auth.BasicAuthentication(username="[email protected]",password="AAA"),
    #isolation_level=prestodb.transaction.IsolationLevel.
)

cur = conn.cursor()
cur.execute("""CREATE TABLE tmp_qiyejinrong.cs20190701_2 as  select *  from 
ods_zhugexh_bdpms.t_info_user_property cusattr""")

output: <prestodb.client.PrestoResult at 0x4a23358>

cur.execute("""desc tmp_qiyejinrong.cs20190701_2""")

output: <prestodb.client.PrestoResult at 0x4a1a898>

cur.fetchone()

output:

PrestoUserError: PrestoUserError(type=USER_ERROR, name=SYNTAX_ERROR, message="line 1:1: Table 'hive.tmp_qiyejinrong.cs20190701_2' does not exist", query_id=20190701_081811_04498_hhbkj)

by the way, i modify the code only to let verify=False,
when the presto platform receive code not like 'select' ,the presto system will use hive to execute the code such as create table or drop table in my company.

@ggreg
Copy link
Contributor

ggreg commented Aug 21, 2019

You need to call cur.fetchone() after executing the CREATE TABLE statement.

@ggreg
Copy link
Contributor

ggreg commented Aug 21, 2019

The SSL warnings is unrelated to your issue.

@ggreg ggreg changed the title can't drop or create table ,but can select * from table !!! Cannot create table Aug 21, 2019
@ggreg
Copy link
Contributor

ggreg commented Aug 21, 2019

Did you expect CREATE TABLE to be executed synchronously (see also #58) or was cur.fetchonne() only missing?

@subbareddydagumati
Copy link

It should execute the CREATE TABLE synchronously like other database modules. currently cur.fetchone() has to be given as a workaround to run the create table statement or any other insert statements.

@alexandermalyga
Copy link

alexandermalyga commented Oct 20, 2022

I agree with @subbareddydagumati in that other DB API implementations do not require cur.fetchonne() in order to execute statements.
The folks over at Trino recently fixed this exact same issue here: trinodb/trino-python-client#220

Could something similar be implemented in the Presto client?

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

4 participants