开发者

Python script to get the data from the flex application

I am making a simple Python CGI script that collects data(in xml format) from a flex application and I want to insert it into the mysql database .

In perl The script is looks like the following...

my @samplexml=$cgi->param("Items");

my $data=$xml->XM开发者_开发百科Lin("@samplexml");

foreach my $e(@{$data->{Group}})
{
   my $sample="Insert into details(title,Parent,Istreeitem) Values('$e->{title}','$e->{Parent}','$e->{IsTreeItem}')";
   my $sam=$dbo->prepare($sample);
   $sam->execute();
}

But I want to know how to write these codes in pytrhon script.... Any one can help me?

Thanks in advance. Nimmy.


It should be fairly easy to convert this to a Python script. Setting the stage:

  1. Python has the cgi module.
  2. Get the Python-MySQL library (or an equivalent for whatever db you're using).
  3. Use Python's xml.etree to parse the incoming XML.

You'd write a Python script that'd read the XML from the CGI variables, parse the xml using xml.etree, make a connection to the database, and execute your exact insert statement. The resulting script should look very similar to the above.


If you're not bound to XML, you can consider pyAMF and flex's remoteobjects or other remoting facilities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜