So I have an issue, I am trying to convert a float value from SQLite Db. The value represents a price in USD and I want to convert it in BTC, I was installing python-forex but because I do not have experience enough I am stack on this:
b = BtcConverter(force_decimal=True)
p = float(acf1.p1)
pbtc = b.convert_to_btc(10, 'USD')
What I need to do is to exchange "10" with "p", and "p" is a row from my SQlite Db.
I was trying to get acfi.p1 from db table with:
acf1 = KAch.query.order_by(KAch.reg.desc()).all()
As well the html code is:
{{ "%.9f" %pbtc }}
But because I am new is giving me 500 error.
Code:
@app.route('/adfa', methods=['GET', 'POST'])
def add_foa():
t1=request.form.get('t1')
c1=request.form.get('c1')
p1=request.form.get('p1')
p2=request.form.get('p2')
um1=request.form.get('um1')
ce1=request.form.get('ce1')
dc1=request.form.get('dc1')
mdla1=request.form.get('mdla1')
mdam1=request.form.get('mdam1')
aop=request.form.get('aop')
pz1=request.form.get('pz1')
users_id = request.form.get('users_id')
acf1 = KAch(
t1=t1,
c1=c1,
p1=p1,
p2=p2,
um1=um1,
ce1=ce1,
dc1=dc1,
mdla1=mdla1,
mdam1=mdam1,
aop=aop,
pz1=pz1,
users_id=current_user.id,
reg=datetime.now())
db.session.add(acf1)
db.session.commit()
return redirect(url_for('adfa', users_id=current_user.id, _external=True))
@app.route('/profil/<int:users_id>')
@login_required
def profil(users_id):
ac1 = KAch.query.order_by(KAch.reg.desc()).all()
user = User.query.filter_by(id=users_id).first()
profil1 = KProfil.query.filter_by(id=users_id).one()
b = BtcConverter(force_decimal=True)
#p = float(acf1.p1)
pbtc = b.convert_to_btc(10, 'USD')
if 'out' in current_user.tc:
return redirect(url_for('adpro', users_id=current_user.id, _external=True))
elif 'n' in current_user.tc:
return redirect(url_for('logout', _external=True))
return render_template('front/usr/usr.html', profil1=profil1, user=user, ac1=ac1, pbtc=pbtc)