0

So I built a postgres models.py and tried to create the below test data, all of which worked with sqlite.

basedir = os.getcwd()

app = Flask(__name__)

#...omitted for brevity

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

app.config['ENV_DB_CONNECTION_DSN'] = 'postgres:///Ocean.db'

db = SQLAlchemy(app)

db.create_all()

#testing starts below this

camelot = Entity(level='Province', name='Camelot',iso_code='CAM')

db.session.add(camelot)

lit = Literal_data(ent_id=1, year=2012, value=2, display_name = 'swallow count', meta_id=1)

db.session.add(lit)

swallow = Meta_indicator_data(p_name = 'swallow count',family = 'animal life',num_type = 'interger',provider = 'camelot bird comission',p_description = 'swallows. duh.')

db.session.add(swallow)

db.session.commit()

the above works fine, i can even query the db with db.engine.execute('select * from ent')

Only problem is I cant find the db file anywhere, including psgadmin III!

any ideas on how to print the db file name? can the above run with no errors without a db file??

Vincent Buscarello
  • 395
  • 2
  • 7
  • 19

1 Answers1

1

Basically my config just sucked I think, been a while since I was dealing with this. the current code reads

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
try:
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
except KeyError:
    raise Exception('I dont see a database connection in the Database URL system variablbe - see the read me on setting this up')

Where:

database_url = postgresql://$user:$password@localhost:5432/$databasename
Saurav Rastogi
  • 9,575
  • 3
  • 29
  • 41
Vincent Buscarello
  • 395
  • 2
  • 7
  • 19