小编Hit*_*ani的帖子

使用stdlib.h中的system()函数在ac程序中使用'rm'命令

我正在尝试使用rm主例程中的命令删除我已采用命令行参数的文件.该值存储在argv[2]我已尝试使用

system("rm argv[2]");

system("rm ./argv[2]");

system("rm $HOME/argv[2]");
Run Code Online (Sandbox Code Playgroud)

但它给我一个错误的说法

"cannot locate file argv[2]"

文件名存储在argv[2]我检查过的位置.

有人请指导我!

c unix

3
推荐指数
2
解决办法
9573
查看次数

使用Postgres在Python中用单引号形成一个insert语句

我有一个叫做评论的字段.我正在有效地尝试将一个大表中的值读入多个表.因此,我的选择查询为我提取注释字段.

我正在构建一个Python脚本来执行从表到表的复制.由于单引号,我的插入查询遇到"抱歉!我们无法处理您的订单"等注释字段时失败.

我试过使用$ quotes但是徒劳无功

这是我正在尝试的

#!/usr/bin/python

import psycopg2

conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' )
mark=conn.cursor()
/* fectching the rows and doing other stuff */

addthis="insert into my_table(something) values("$$"+str(row[8])+"$$")
mark.execute(addthis)
conn.commit()
Run Code Online (Sandbox Code Playgroud)

感谢帮助!

python postgresql psycopg2 postgresql-8.4

1
推荐指数
1
解决办法
2005
查看次数

更新查询php postgres无缘无故失败

我在PHP中使用这段代码并使用PostgreSQL作为数据库.我从GET获得所有参数.通过打印检查了它们.形成的查询在Postgres终端上执行,但是从PHP脚本失败.

这是一段代码.

<?php

$link = pg_connect("host=localhost dbname=postgres user=postgres password=password") or die('connection failed');

# Building the query
$newq=sprintf("update purchase_info set ....... comments=%s where id=%s",......,$comm,$id);

    print $newq; // This query runs on the postgres terminal
    $query=addslashes($newq); // to escape "" as one of my fields is comments
    $result=pg_query($link,$newq);

    if (!$result) {
        echo "An error occured.\n";
    }
    pg_close($link);
?>
Run Code Online (Sandbox Code Playgroud)

其他查询在同一脚本中运行.此SQL语句有大约14个字段正在更新.

听到了什么问题.感谢帮助!

php postgresql postgresql-8.4

1
推荐指数
1
解决办法
1653
查看次数

标签 统计

postgresql ×2

postgresql-8.4 ×2

c ×1

php ×1

psycopg2 ×1

python ×1

unix ×1