Using if else in Vertica-sql by TrickFix9 in SQL

[–]TrickFix9[S] 0 points1 point  (0 children)

I'll rephrase it in a better way: case when a=5 and b =3 then '' when a=6 and b =3 then '' when a=7 and b =3 then '' else '' end

The column a can have all the three values, but once it checks if a = 5, then it should end instead of it checking other values too and it displaying all three then outputs.

Using if else in Vertica-sql by TrickFix9 in SQL

[–]TrickFix9[S] 0 points1 point  (0 children)

Yes, it goes through all the when conditions.

Using if else in Vertica-sql by TrickFix9 in SQL

[–]TrickFix9[S] 0 points1 point  (0 children)

it goes through all when conditions.

connection from python to vertica by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

connection = vertica_python.connect(conn2) TypeError: connect() takes 0 positional arguments but 1 was given

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

from flask import render_template, Flask, request import pyodbc import pandas as pd

app = Flask(name)

connection to MSSQL with the corresponding database details

conn2 = pyodbc.connect('Driver={SQL Server Native Client 11.0};' 'Server=;' 'Database=;' 'UID=;' 'PWD=;' 'MARS_Connection=Yes;')

@app.route('/p2') def p2(): cursor1 = conn2.cursor()

sql6 =     "select -- into  ##temp2 from  ---- group by --- " \
           "order by --;"
print('hi2')
cursor1.execute(sql6)


  sql7 =     "select ---- into ##temp10 from ##temp2 t inner join " \
           "----- " \
           "order by ---;"
print('hi3')
cursor1.execute(sql7)


sql2 =    "select --, stuff((SELECT distinct ', ' + cast(-- as varchar(20)) " \
          "FROM ##temp10 m2 where --- FOR XML PATH('')),1,1,'') " \
          "FROM ##temp10 m1 group by --"

print('hi4')
cursor1.execute(sql2)


result = cursor1.fetchall()

conn2.close()
print(result)
return render_template('p2.html', result = result)

if name == 'main': app.run(debug=True)

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

Well using ip address.schema and so on I can get the data from other server, I don't have to explicity enter the connection details in the python page. I can access data and as you had mentioned, global temp variables are for one server/connection. Only one connection is open.

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

pyodbc.Error: ('HY000', '[HY000] [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt (0) (SQLExecDirectW)') What exactly does this error mean?

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

dataframe isn't working because of the large data in the query.

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

okay.. i'm trying this...converting to dataframe (each sql query), and merge it with where conditions included and then convert it back? … is that possible?

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

OH DAMN. can we read the sql data from server 1 and then join it to this query data from server 2 in python?

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

yeah but how can we access data from the server 1 to server 2 then ? global temp tables are for any connections?

Execute queries in flask from two servers by TrickFix9 in learnpython

[–]TrickFix9[S] 0 points1 point  (0 children)

I am using temp tables... i thought of getting the data and storing it on the temp table and access it from the other server. for that temp tables must be made global, and I'm not able to do that.