[英]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:使用 this.sh,我可以使用 DSBulk 加载器将 a.csv 文件加载到 Apache Cassandra 中:
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.使用.sh 显示,我正在创建一个 Python GUI 以使用按钮加载.csv 数据。 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?
我可以使用该按钮加载数据,但是,如何选择必须打开和加载的.csv 文件? I used a similar function in a different way but not to choose a file opened from the.sh.
我以不同的方式使用了类似的 function 但没有选择从 .sh 打开的文件。
This is the function of the button:这是按钮的function:
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在.sh上必须写
echo "you selected $(zenity --file-selection)"
then, the action needed es: dsbulk....然后,需要执行的操作 es: dsbulk....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.