Skip to content

Instantly share code, notes, and snippets.

@jvanasco
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvanasco/2ff0b9a31ac45198a060 to your computer and use it in GitHub Desktop.
Save jvanasco/2ff0b9a31ac45198a060 to your computer and use it in GitHub Desktop.
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
import sqlalchemy.exc
import base64
Base = declarative_base()
class Friends(Base):
__tablename__ = 'friends'
id = Column(Integer, primary_key=True)
name = Column(String(50))
e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)
s = Session(e)
def post_insert(username):
"""original function"""
conn = engine.connect()
puresql = sqla.text("INSERT INTO friends(name) VALUES(:encoded)")
conn.execute(puresql,encoded = encoded)
username = "12345678"
encoded = base64.b64encode(username.encode('utf-8'))
puresql = sqlalchemy.text("INSERT INTO friends(name) VALUES(:encoded)")
s.connection().execute( puresql, encoded = encoded )
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment