from sqlalchemy import Column, Integer, String, DateTime, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine

Base = declarative_base()

class Candidates(Base):
    __tablename__ = 'candidates'
    # Here we define columns for the table
    # Notice that each column is also a normal Python instance attribute.
    id = Column(Integer, primary_key=True)
    time = Column(DateTime, nullable=False)
    dm = Column(Float, nullable=False)
    antenna = Column(String(8), nullable=False)
    experiment = Column(String(8), nullable=False)

# Create an engine that stores data in the local directory's
# sqlalchemy_example.db file.
engine = create_engine('sqlite:///sqlalchemy_example.db')

# Create all tables in the engine. This is equivalent to "Create Table"
# statements in raw SQL.
Base.metadata.create_all(engine)


from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

engine = create_engine('sqlite:///sqlalchemy_example.db')
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Insert a Person in the person table
new_candidate = Candidates(time=None, dm=100., antenna='EFF',
                           experimet='re03jy')
session.add(new_candidate)
session.commit()

@@ -578,16 +578,18 @@
 False)%0A%0A
+# 
 # Create
@@ -642,16 +642,18 @@
 tory's%0A#
+ #
  sqlalch
@@ -673,16 +673,18 @@
 b file.%0A
+# 
 engine =
@@ -733,17 +733,20 @@
 le.db')%0A
-%0A
+#%0A# 
 # Create
@@ -810,16 +810,18 @@
 Table%22%0A#
+ #
  stateme
@@ -836,16 +836,18 @@
 aw SQL.%0A
+# 
 Base.met
@@ -871,18 +871,22 @@
 engine)%0A
-%0A%0A
+#%0A#%0A# 
 from sql
@@ -914,16 +914,18 @@
 _engine%0A
+# 
 from sql
@@ -956,17 +956,20 @@
 onmaker%0A
-%0A
+#%0A# 
 engine =
@@ -1019,16 +1019,18 @@
 e.db')%0A#
+ #
  Bind th
@@ -1085,16 +1085,18 @@
 at the%0A#
+ #
  declara
@@ -1146,16 +1146,18 @@
 nstance%0A
+# 
 Base.met
@@ -1176,17 +1176,20 @@
  engine%0A
-%0A
+#%0A# 
 DBSessio
@@ -1219,16 +1219,18 @@
 ngine)%0A#
+ #
  A DBSes
@@ -1294,16 +1294,18 @@
 tabase%0A#
+ #
  and rep
@@ -1366,16 +1366,18 @@
 to the%0A#
+ #
  databas
@@ -1438,16 +1438,18 @@
 in the%0A#
+ #
  session
@@ -1502,16 +1502,18 @@
 u call%0A#
+ #
  session
@@ -1571,16 +1571,18 @@
 ou can%0A#
+ #
  revert 
@@ -1629,16 +1629,18 @@
 alling%0A#
+ #
  session
@@ -1651,16 +1651,18 @@
 lback()%0A
+# 
 session 
@@ -1676,16 +1676,18 @@
 sion()%0A%0A
+# 
 # Insert
@@ -1716,16 +1716,18 @@
 n table%0A
+# 
 new_cand
@@ -1780,16 +1780,18 @@
 ='EFF',%0A
+# 
         
@@ -1817,16 +1817,17 @@
 experime
+n
 t='re03j
@@ -1830,16 +1830,18 @@
 e03jy')%0A
+# 
 session.
@@ -1859,16 +1859,18 @@
 didate)%0A
+# 
 session.
@@ -1878,8 +1878,119 @@
 ommit()%0A
+%0A%0Adef save_to_candidates_db(*args, **kwargs):%0A    pass%0A%0A%0Adef save_to_processed_db(*args, **kwargs):%0A    pass%0A%0A%0A

comment out for now