Ross

That's all I'm looking for is what others are doing to manage the situation. I should have specified that I'm using MySQL. When I'm at the office, it is a different server on the network. When at home or on my laptop I'm running a local copy of MySQL.

Before web2py I was using TurboGears 1 which is all config-file based. That worked well because I just kept a different config file on each machine and didn't have on in my repo.

Thanks again for the input, I appreciate it.

    -Jim

On 1/10/2012 9:10 AM, Ross Peoples wrote:
On my dev machines, I'm using SQLite, so the database is the same regardless of what machine I'm using. In your case, you could set your db.py file to detect your machine's host name and use the appropriate DAL string accordingly.

For example:

import socket
hostname = socket.gethostname()

if hostname == 'dev1':
    db = DAL('postgres://123.45.168.90/mydb')
elif hostname == 'dev2':
    db = DAL('postgres://98.76.43.21/mydb')
else:
    # production database
    db = DAL('postgres://22.33.44.55/productiondb')


Another option, which I used to use is to set up the database on your primary dev machine (probably your home workstation), then when using your laptop, set up an SSH tunnel, forwarding the database port. You would still have to use the method above, since your laptop would see your home database server as running locally, but at least this way you can work with the same database all the time.

The second option may or may not be good for you, but that's up to you....I'm just making sure I give you a couple of options to chose from.

Reply via email to