Skip to content

Instantly share code, notes, and snippets.

@Stiivi
Created June 3, 2014 22:19
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 Stiivi/4fc4d05ab376f82dca88 to your computer and use it in GitHub Desktop.
Save Stiivi/4fc4d05ab376f82dca88 to your computer and use it in GitHub Desktop.
from sqlalchemy import create_engine, MetaData, Table, Integer, Date, Column
import sqlalchemy.sql as sql
engine = create_engine("sqlite://")
md = MetaData(bind=engine)
table = Table("data", md)
table.append_column(Column("id", Integer))
table.append_column(Column("adate", Date))
table.append_column(Column("value", Integer))
data = [
{"id": 1, "value": "foo", "adate": sql.func.now()},
{"id": 2, "value": "bar", "adate": sql.func.now()}
]
print str(table.insert().values(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment