简体   繁体   中英

How to create a button for Python GUI to load data into Cassandra via .sh file choosing a .csv

With this.sh I can load a.csv file into Apache Cassandra using DSBulk loader:

export PATH=/home/workstation/dsbulk-1.7.0/bin:$PATH

source ~/.bashrc

dsbulk load -url /home/workstation/ll/datatest.csv -k test_keyspace -t test_data  -delim "," -header false 

Using the.sh showed, I'm creating a Python GUI to load the.csv data with a button. So, I've implemented the code below. I can load data with that button, but, how can I choose the.csv file which must be opened and loaded? I used a similar function in a different way but not to choose a file opened from the.sh.

This is the function of the button:

def Dataloader():
   
   subprocess.call('./tester.sh', shell=True)


button = Button(window, text=" Load data into APC ", bg="black", fg="white",command=Dataloader)

Some suggestion? Where am I going wrong?

Thank you

Solution:

on the.sh must be written

echo "you selected $(zenity --file-selection)"

then, the action needed es: dsbulk....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM