Hey new issue.  wonder if you have any experience with pymysql or oracle 
myql connector python for connecting python3 web app to mysql.  Heres my 
post: 

How can I import a dbconnection function in PyMySQL like MySQLdb below? Ive 
tried this and my app is broken. : 

dbconnect.py file (to be used in different parts of web app) :


import pymysql
def connection():
    conn = pymysql.connect(host = "localhost",
                           user = "root",
                           passwd = "mysqlroot",
                           db = "sqltest")

    c = conn.cursor()
    return c, conn



init.py web app file (testing the module on register page):


from dbconnect import connection
@app.route('/register/', methods=["GET","POST"])def register_page():
    try:
        c, conn = connection()
        return("okay, flask to db connection appears to be working")
    except Exception as e:
        return(str(e))


EDIT: calling the connection() function works with MySQLdb module but not 
with pymysql or mysql.connector, it just makes no sense and very 
frustrating.   Heres apache error log after above connection attempt (says 
ImportError no module "dbconnect" yet there is and once Im in python3 shell 
I can import it fine) :


[Tue Apr 26 21:48:02.125650 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] mod_wsgi (pid=23265): Target 
WSGI script '/var/www/site1/FlaskApp/flaskapp.wsgi' cannot be loaded as 
Python module., referer: http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125714 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] mod_wsgi (pid=23265): 
Exception occurred processing WSGI script 
'/var/www/site1/FlaskApp/flaskapp.wsgi'., referer: http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125739 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] Traceback (most recent call 
last):, referer: http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125856 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] File 
"/var/www/site1/FlaskApp/flaskapp.wsgi", line 6, in , referer: 
http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125861 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] from FlaskApp import app as 
application, referer: http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125933 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] File 
"/var/www/site1/FlaskApp/FlaskApp/*init*.py", line 2, in , referer: 
http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125938 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] from dbconnect import 
connection, referer: http://site1.me/


<http://site1.me/>

[Tue Apr 26 21:48:02.125954 2016] [wsgi:error] [pid 23265:tid 
139993628493568] [client 192.168.1.100:53645] ImportError: No module named 
'dbconnect', referer: http://site1.me/

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to