Search the Community
Showing results for tags 'psycopg2'.
-
Hi I would like you to install the psycopg2 module. postgresql wont work without it. thanks in anticipation.
-
Hi I have a flask application that runs perfectly when passing a json package, and returns the same package to the client with no problems but when importing psycopg2 the json package returned is "None" and client complain about the parsing something that is not a json package. Working Code using json library: #!/usr/bin/env pythonimport sys#import psycopg2import jsonfrom flask import Flask,request,jsonify, __version__app = Flask(__name__)application = app @app.route("/")def hello(): return """ HelioHost rules!<br><br> <a href="/flask/python/version/">Python version</a><br> <a href="/flask/flask/version/">Flask version</a> """ @app.route("/python/version/")def p_version(): return "Python version %s" % sys.version @app.route("/flask/version/")def f_version(): return "Flask version %s" % __version__ @app.route("/mother")def mother(): return "Hello world mother" @app.route("/jsonp",methods=['POST'])def jsonp(): webdatajson = request.get_json() # get json package #datajson = jsonify(webdatajson) #make a json package to send back datajson = json.dumps(webdatajson) #makes a json package to send back return(datajson) if __name__ == "__main__": app.run() Another working code using jsonify from flask: #!/usr/bin/env pythonimport sys#import psycopg2import jsonfrom flask import Flask,request,jsonify, __version__app = Flask(__name__)application = app @app.route("/")def hello(): return """ HelioHost rules!<br><br> <a href="/flask/python/version/">Python version</a><br> <a href="/flask/flask/version/">Flask version</a> """ @app.route("/python/version/")def p_version(): return "Python version %s" % sys.version @app.route("/flask/version/")def f_version(): return "Flask version %s" % __version__ @app.route("/mother")def mother(): return "Hello world mother" @app.route("/jsonp",methods=['POST'])def jsonp(): webdatajson = request.get_json() # get json package datajson = jsonify(webdatajson) #make a json package to send back #datajson = json.dumps(webdatajson) #makes a json package to send back return(datajson) if __name__ == "__main__": app.run() NOT WORKING CODE once importing psycopg2: #!/usr/bin/env pythonimport sysimport psycopg2import jsonfrom flask import Flask,request,jsonify, __version__app = Flask(__name__)application = app @app.route("/")def hello(): return """ HelioHost rules!<br><br> <a href="/flask/python/version/">Python version</a><br> <a href="/flask/flask/version/">Flask version</a> """ @app.route("/python/version/")def p_version(): return "Python version %s" % sys.version @app.route("/flask/version/")def f_version(): return "Flask version %s" % __version__ @app.route("/mother")def mother(): return "Hello world mother" @app.route("/jsonp",methods=['POST'])def jsonp(): webdatajson = request.get_json() # get json package #datajson = jsonify(webdatajson) #make a json package to send back datajson = json.dumps(webdatajson) #makes a json package to send back return(datajson) if __name__ == "__main__": app.run() I'm trying to get the json from the client and then store the data into the postgresql that is why i need the psycopg2 adapter. Is this adapter installed or am I doing something wrong? Also for the future when connecting to the postgresql database from the flask app how should I specify the host? ("http://localhost:5432" or "http://ricky.heliohost.org:5432") Thanks in advanced Forgot to mention my data username: ioteche domain: ioteche.heliohost.org server: Ricky