Re: Unable to insert data into MongoDB.

2016-02-16 Thread Arjun Srivatsa
Thanks a lot. Will implement that. Although I am able to do using just 2 scripts as well. On Monday, February 15, 2016 at 5:34:08 PM UTC+1, Peter Otten wrote: > Arjun Srivatsa wrote: > > > Hi Peter. > > > > Thank you for the reply. > > > > This is the read_server code: > > > > import socket

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Peter Otten
Arjun Srivatsa wrote: > Hi Peter. > > Thank you for the reply. > > This is the read_server code: > > import socket > from pymongo import MongoClient > #import datetime > import sys > > # Connection to server (PLC) on port 27017 > host = "10.52.124.135" > port = 27017 > > s = socket.socket(soc

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Arjun Srivatsa
Okay, I added with open('yourfile','w') as f: f.write(data) to the read_server code in which the Actual data is stored in a file on my desktop. Then, it must be possible to read this file in the Write_db script to insert the data. On Monday, February 15, 2016 at 4:00:37 PM UTC+1, Arjun

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Arjun Srivatsa
Hi Peter. Thank you for the reply. This is the read_server code: import socket from pymongo import MongoClient #import datetime import sys # Connection to server (PLC) on port 27017 host = "10.52.124.135" port = 27017 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, por

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Peter Otten
Arjun Srivatsa wrote: > I changed the port number from 27017 to 5 in the code segment: Instead of throwing arbitrary changes at your script in the hope that one works I recommend that you write two independent scripts, from scratch: (1) write_to_db.py: Write made-up data into the MongoDB o

Re: Unable to insert data into MongoDB.

2016-02-15 Thread Arjun Srivatsa
I changed the port number from 27017 to 5 in the code segment: IP = "127.0.0.1" PORT = 27017 BUFFER_SIZE = 1024 client = MongoClient('127.0.0.1', 27017) And my output on Python shell is: hello world! Connection address: ('127.0.0.1', 16951) Connection address: ('127.0.0

Re: Unable to insert data into MongoDB.

2016-02-11 Thread Arjun Srivatsa
Hello, I changed PORT = 27017 to PORT = 5. I am not getting the error anymore. But I am still unable to insert the data into MongoDB. On Thursday, February 11, 2016 at 4:12:30 PM UTC+1, Arjun Srivatsa wrote: > Hi guys. I am basically transferring the data from PLC to PC (where

Re: Unable to insert data into MongoDB.

2016-02-11 Thread MRAB
On 2016-02-11 15:12, Arjun Srivatsa wrote: Hi guys. I am basically transferring the data from PLC to PC (where the Python API runs) but I'm unable to insert into MongoDB thereafter. When I run the Python script on IDLE, the output is Hello World! Traceback (most recent call last): File "C:\Use

Unable to insert data into MongoDB.

2016-02-11 Thread Arjun Srivatsa
Hi guys. I am basically transferring the data from PLC to PC (where the Python API runs) but I'm unable to insert into MongoDB thereafter. When I run the Python script on IDLE, the output is Hello World! Traceback (most recent call last): File "C:\Users\SRA2LO\Desktop\API.py", line 32, in s.bi