我是一个php开发人员。我正在尝试用pyqt创建一个小应用程序 我使用这个代码,它工作得很好
import psycopg2
try:
myConnection = psycopg2.connect(host="localhost", user="openpg", password="", dbname="dbLaSolve")
conn = myConnection.cursor()
except(Exception, psycopg2.Error) as error :
if(myConnection):
print("Failed to insert record", error)
sql = "insert into trens(nom,prenom)VALUES('RASOLO','Solofo')"
conn.execute(sql)
myConnection.commit()
但我想把它分成两个文件 康涅狄格州零件连接和 插入.py在postgreql表中插入数据 像这样的人谁知道php
你知道吗康奈克斯.php你知道吗
try
{
$conn = new PDO('mysql:host=localhost;dbname=dbLaSolve','root','');
}
catch(Exception $err)
{
echo "Erreur de connexion à la base de donnée: ".$err->getMessage();
exit();
}
你知道吗插入.php你知道吗
require_once("connex.php");
$sql = "INSERT INTO trens ( `nom`, `prenom`)VALUES ('RASOLO','Solofo')";
$conn->exec($sql );
文件: 康奈克斯公司你知道吗
文件呢 插入.py(导入de connex)
相关问题 更多 >
编程相关推荐