Python 用脚本填充Sql表

Python 用脚本填充Sql表,python,mysql,shell,tcsh,Python,Mysql,Shell,Tcsh,我有一个SQL数据库,我想用脚本填充表。以下源代码显示了我到目前为止所做的工作: #!/bin/tcsh mysql -h dbs1 -D my_devel -u USER --password=XYZ insert into my_table ( col_id, type, file, result, signature) values (***,'###','+++','$$$','...'); exit 根据这一点,我通过python中定义的方法传递参数“*”、“#

我有一个SQL数据库,我想用脚本填充表。以下源代码显示了我到目前为止所做的工作:

  #!/bin/tcsh
   mysql -h dbs1 -D my_devel -u USER --password=XYZ
   insert into my_table ( col_id, type, file, result, signature) values (***,'###','+++','$$$','...');
   exit
根据这一点,我通过python中定义的方法传递参数“*”、“#”、“+”、“$”和“.”


但不知怎么的,这对我不起作用。有人能告诉我为什么,或者提出一个替代方案吗?

根据Martijn的评论,连接MySQL数据库最简单的方法之一是使用。

这对我来说似乎很好:

#!/bin/tcsh

# count-rows.csh

mysql -h 127.0.0.1 -D tpcw -u root <<EOF
select count(*) from $1;
exit
EOF
#/垃圾箱/垃圾箱
#count-rows.csh

mysql-h 127.0.0.1-D tpcw-u root为什么不使用python直接连接到mysql?