i have a problemi have a sql query written that has to be passed to the python code and it has to come into an excel sheet ,but im new to this connection part of python ,i dont no can anyone please help me. this is my login credentials
1)Db Credentials:
Hostname: INBLR-LVTEMP.IN.valtech.com
Port: 1521
SID: xstore
Username: dtv
Password: dtv
select * from itm_item;
select * from trl_sale_lineitm;
select * from xom_order;
SELECT
LRL.AREA AS AREA,
LRL.COUNTRY AS COUNTRY,
LRL.CURRENCY_ID AS CURRENCY,
LRL.RTL_LOC_ID AS STORE_CODE,
TO_CHAR(TSL.BUSINESS_DATE, 'DD/MM/YYYY') AS BUSINESS_DATE,
TSL.WKSTN_ID AS WKSTN_ID,
TSL.TRANS_SEQ AS TRANS_SEQ,
TSL.RTRANS_LINEITM_SEQ AS LINEITEM_SEQ,
TSL.ITEM_ID AS SKU,
ITM.DESCRIPTION AS ITM_DESC,
TSL.QUANTITY AS QTTY,
TSL.RETURN_FLAG AS RETURN_FLAG,
TSL.UNIT_PRICE AS UNIT_PRICE,
TSL.NET_AMT AS NET_AMT,
TSL.EXTENDED_AMT AS EXTENDED_AMT,
PT.CUST_ID AS CUST_ID,
EMP.LOGIN_ID AS COMISSIONED_CA,
OM.ORDER_ID AS ORDER_ID,
CIAA.CUST_ACCT_ID AS RESERVATION_ID,
CASE WHEN TSTL.TAX_EXEMPTION_ID is not NULL THEN 'yes' ELSE 'no' END AS IS_TAX_EXEMPTION,
CI_CIX.EXT_INVOICE_ID AS GLOBAL_BLUE_TRN_NBR,
TSL.CREATE_DATE AS CREATE_DATE,
NVL(TSL.UPDATE_DATE, TSL.CREATE_DATE) AS UPDATE_DATE,
'Retail sale' AS TRANS_TYPE,
TSTL.TAX_AMT AS TAX_AMT,
TSL.GROSS_AMT AS GROSS_AMT,
TTN.NOTE,
CONCAT(LPAD(TSL.WKSTN_ID,3,0), LPAD(TSL.TRANS_SEQ,6,0)) AS "SAP REF KEY 2"
FROM
TRL_SALE_LINEITM TSL
LEFT JOIN TRN_TRANS TT ON 1 = 1
AND TT.TRANS_SEQ = TSL.TRANS_SEQ
AND TT.ORGANIZATION_ID = TSL.ORGANIZATION_ID
AND TT.BUSINESS_DATE = TSL.BUSINESS_DATE
AND TT.WKSTN_ID = TSL.WKSTN_ID
AND TT.RTL_LOC_ID = TSL.RTL_LOC_ID
LEFT JOIN TRL_RTRANS_LINEITM TRL ON 1 = 1
AND TRL.TRANS_SEQ = TSL.TRANS_SEQ
AND TRL.ORGANIZATION_ID = TSL.ORGANIZATION_ID
AND TRL.BUSINESS_DATE = TSL.BUSINESS_DATE
AND TRL.WKSTN_ID = TSL.WKSTN_ID
AND TRL.RTL_LOC_ID = TSL.RTL_LOC_ID
AND TRL.RTRANS_LINEITM_SEQ = TSL.RTRANS_LINEITM_SEQ
LEFT JOIN ITM_NON_PHYS_ITEM INPI ON 1 = 1
AND INPI.ITEM_ID = TSL.ITEM_ID
LEFT JOIN XOM_ORDER_MOD XOM ON 1 = 1
AND XOM.TRANS_SEQ = TSL.TRANS_SEQ
AND XOM.ORGANIZATION_ID = TSL.ORGANIZATION_ID
AND XOM.BUSINESS_DATE = TSL.BUSINESS_DATE
AND XOM.WKSTN_ID = TSL.WKSTN_ID
AND XOM.RTL_LOC_ID = TSL.RTL_LOC_ID
AND XOM.RTRANS_LINEITM_SEQ = TSL.RTRANS_LINEITM_SEQ
LEFT JOIN TRL_RTRANS RT ON 1 = 1
AND RT.RTL_LOC_ID = TSL.RTL_LOC_ID
AND RT.BUSINESS_DATE = TSL.BUSINESS_DATE
AND RT.WKSTN_ID = TSL.WKSTN_ID
AND RT.TRANS_SEQ = TSL.TRANS_SEQ
LEFT JOIN CRM_PARTY PT ON 1 = 1
AND PT.PARTY_ID = RT.CUST_PARTY_ID
LEFT JOIN TRL_COMMISSION_MOD CM ON 1 = 1
AND CM.RTL_LOC_ID = TSL.RTL_LOC_ID
AND CM.BUSINESS_DATE = TSL.BUSINESS_DATE
AND CM.WKSTN_ID = TSL.WKSTN_ID
AND CM.TRANS_SEQ = TSL.TRANS_SEQ
AND CM.RTRANS_LINEITM_SEQ = TSL.RTRANS_LINEITM_SEQ
LEFT JOIN HRS_EMPLOYEE EMP ON 1 = 1
AND EMP.PARTY_ID = CM.EMPLOYEE_PARTY_ID
LEFT JOIN ITM_ITEM ITM ON 1 = 1
AND ITM.ITEM_ID = TSL.ITEM_ID
LEFT JOIN TRN_TRANS_NOTES TTN ON 1 = 1
AND TTN.TRANS_SEQ = TSL.TRANS_SEQ
AND TTN.ORGANIZATION_ID = TSL.ORGANIZATION_ID
AND TTN.BUSINESS_DATE = TSL.BUSINESS_DATE
AND TTN.WKSTN_ID = TSL.WKSTN_ID
AND TTN.RTL_LOC_ID = TSL.RTL_LOC_ID
AND TTN.NOTE_SEQ = 1
LEFT JOIN (
SELECT
RTL_LOC_ID,
BUSINESS_DATE,
WKSTN_ID,
TRANS_SEQ,
RTRANS_LINEITM_SEQ,
SUM(TAX_AMT) TAX_AMT,
TAX_EXEMPTION_ID
FROM
TRL_SALE_TAX_LINEITM
GROUP BY
(
RTL_LOC_ID,
BUSINESS_DATE,
WKSTN_ID,
TRANS_SEQ,
RTRANS_LINEITM_SEQ,
TAX_EXEMPTION_ID
)
) TSTL ON 1 = 1
AND TSTL.TRANS_SEQ = TSL.TRANS_SEQ
AND TSTL.BUSINESS_DATE = TSL.BUSINESS_DATE
AND TSTL.RTL_LOC_ID = TSL.RTL_LOC_ID
AND TSTL.WKSTN_ID = TSL.WKSTN_ID
AND TSTL.RTRANS_LINEITM_SEQ = TSL.RTRANS_LINEITM_SEQ
LEFT JOIN (
SELECT
*
FROM
CIVC_INVOICE_XREF CIX
LEFT JOIN CIVC_INVOICE CI ON CIX.RTL_LOC_ID = CI.RTL_LOC_ID
AND CIX.SEQUENCE_NBR = CI.SEQUENCE_NBR
AND CIX.WKSTN_ID = CI.WKSTN_ID
AND CIX.TRANS_BUSINESS_DATE = CI.BUSINESS_DATE
WHERE
CI.VOID_FLAG != 1
AND CI.INVOICE_TYPE = 'TAXFREE'
) CI_CIX ON 1 = 1
AND CI_CIX.TRANS_RTL_LOC_ID = TSL.RTL_LOC_ID
AND CI_CIX.TRANS_BUSINESS_DATE = TSL.BUSINESS_DATE
AND CI_CIX.TRANS_TRANS_SEQ = TSL.TRANS_SEQ
AND CI_CIX.TRANS_WKSTN_ID = TSL.WKSTN_ID
LEFT JOIN XOM_ORDER_MOD OM ON 1 = 1
AND TSL.TRANS_SEQ = OM.TRANS_SEQ
AND TSL.ORGANIZATION_ID = OM.ORGANIZATION_ID
AND TSL.BUSINESS_DATE = OM.BUSINESS_DATE
AND TSL.RTL_LOC_ID = OM.RTL_LOC_ID
AND TSL.WKSTN_ID = OM.WKSTN_ID
AND TSL.RTRANS_LINEITM_SEQ = OM.RTRANS_LINEITM_SEQ
LEFT JOIN LOC_RTL_LOC LRL ON 1 = 1
AND TSL.RTL_LOC_ID = LRL.RTL_LOC_ID
AND LRL.ORGANIZATION_ID = TSL.ORGANIZATION_ID
OUTER APPLY (
SELECT
CUST_ACCT_ID
FROM
CAT_CUST_ITEM_ACCT_ACTIVITY CIAA
WHERE
TSL.TRANS_SEQ = CIAA.TRANS_SEQ
AND TSL.ORGANIZATION_ID = CIAA.ORGANIZATION_ID
AND TSL.BUSINESS_DATE = CIAA.BUSINESS_DATE
AND TSL.RTL_LOC_ID = CIAA.RTL_LOC_ID
AND TSL.WKSTN_ID = CIAA.WKSTN_ID
AND TSL.RTRANS_LINEITM_SEQ = CIAA.RTRANS_LINEITM_SEQ
AND ROWNUM = 1
) CIAA
WHERE 1=1
AND TRL.VOID_FLAG = 0
AND TT.POST_VOID_FLAG = 0
AND TT.TRANS_STATCODE = 'COMPLETE'
AND TSL.BUSINESS_DATE BETWEEN TO_DATE('01-DEC-2018', 'DD-MON-YYYY')
AND TO_DATE(TO_DATE('31-DEC-2018', 'DD-MON-YYYY'))
AND TSL.RTL_LOC_ID IN (SELECT RTL_LOC_ID FROM LOC_RTL_LOC where country='US')
--AND TSL.WKSTN_ID >= ?
--AND TSL.WKSTN_ID <= ?
AND TSL.ITEM_ID not in (select ITEM_ID from ITM_NON_PHYS_ITEM where NON_PHYS_ITEM_TYPCODE in ('DEPOSIT_PAYMENT', 'VOUCHER', 'GIFT_REFUND','ORDER_ACCOUNT_CREDIT'))
AND (TSL.SALE_LINEITM_TYPCODE IN ('SALE', 'SEND_SALE') OR TSL.SALE_LINEITM_TYPCODE IN ('ORDER') AND TSL.RETURN_FLAG = 1)
order by create_date;
import pymssql
import pandas as pd
server = '1521'
username = 'dtv'
password = 'dtv'
database = 'yourdatabase'
table_name = 'xom_order'
conn = pymssql.connect(host=1521,user=dtv,password=dtv,database=database)
dat = pd.read_sql("select * from itm_item,conn)
i have tried different ways to do this still im not able please can anyone help me out,so i have tried this method but im not able to execute correctly .
"I expect the output to be as follows when u run that sql query in python code the results what u get has to be placed in an excel sheet automatically"
python-3.x
cb.bind('<<ComboboxSelected>>', on_select)to run your own functionon_selectwhen you change selection - and in this function you may have to has to change values in other Combobox. Simple example: combobox-get-selectionIntVarthat you are trying to setStrings to. All your*Varexcept forv1andv2are actually unused. It is unclear what you are trying to do or show.Tk()and only onemainloop(). In my code I used namerootbecause it is popular name in all examples and tutorial but you usewindow- so use onlywindowin code and removeroot.