4985

Web2py: pass parameters to db Connection()

Question:

In web2py, in gluon/contrib/pymysql/connections.py there is a function that creates a new mySQL connection:

def __init__(self, host="localhost", user=None, passwd="", db=None, port=3306, unix_socket=None,

Is there any way to pass parameters to this function from web2py?

Answer1:

As noted at the very end of <a href="http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Note-on-new-DAL-and-adapters" rel="nofollow">this section</a> of the documentation, you can specify a dictionary of driver_args when instantiating DAL:

db = DAL(<connection_string>, driver_args=dict(host='localhost', port=3306, ...))

Recommend

  • Python PyQt5: Store image data into a phpmyadmin database
  • python - self - required positional argument [duplicate]
  • Formatting in pymysql multiline statement
  • Reading from mysql tables using pandas and named parameters in query
  • mysql_* to MySQLi
  • Connect to remote MySQL via Python
  • How can we get list of non-system users on linux?
  • Installing samr in in R 3.4
  • Android NFC read Tags issue. Activity starts each time on data received
  • Grunt watch Running “watch” task Waiting
  • openssl handshake failed
  • How to resolve docker host names (/etc/hosts) in containers
  • Python Tkinter after event OOPS implementation
  • MRO with multiple inheritance in python
  • CORS with socket.io
  • Faster Way To Simultaneously Iterate Over Rolling Window Of Two Or More Numpy Arrays?
  • Django return user model id with L
  • mave 3.2 not able to access local nexus instance return 502 code
  • Why are YouTube videos using 'youtube.com/v' not loading
  • MYSQ & MVC3 SQL connection error \\ ProviderManifestToken but I am using MySQL
  • Tomcat memory Leak
  • Suppressing passwd when calling sqlplus from shell script
  • Check for zero lines output from command over SSH
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • error importing numpy
  • Grails calculated field in SQL
  • Moving mysql files across servers
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Cannot resolve symbol 'MyApi'
  • How to add date and time under each post in guestbook in google app engine
  • How to check if every primary key value is being referenced as foreign key in another table
  • JSON with duplicate key names losing information when parsed
  • Display Images one by one with next and previous functionality
  • Return words with double consecutive letters
  • Comma separated Values
  • need help with bizarre java.net.HttpURLConnection behavior
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF