Insert new column in an existing database

13 views
Skip to first unread message

Jothybasu Selvaraj

unread,
Dec 3, 2015, 12:19:41 AM12/3/15
to sqlalchemy
Dear All

I just started to use sqlalchemy and I am also quite new to databases.

I have a sqlite database saved with a table with name "Table1" and now I want to insert a colum with PickleType. The below code works for TEXT, INTEGER, etc... but not for PickleType. 




curResults13={'Output':2.01,'QualityIndex':0.66,'FlatnessX':1.5,'FlatnessY=':1.8}

conn = sqlite3.connect("C:\\MLC QA\LA4.db")
c = conn.cursor()
c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct} DEFAULT '{df}'"\
.format(tn='Table1', cn='Results', ct='ARRAY', df=curResults13))
conn.commit()
conn.close()



Can any of you guide me on this issue?



Thanks


Jothy



Mike Bayer

unread,
Dec 3, 2015, 11:49:35 AM12/3/15
to sqlal...@googlegroups.com

hello -

you need to use the SQLAlchemy API fully, the code example below is
using the SQLite DBAPI directly.

Go through the tutorial at
http://docs.sqlalchemy.org/en/rel_1_0/core/tutorial.html to see how to
properly invoke SQL with SQLAlchemy.
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy+...@googlegroups.com
> <mailto:sqlalchemy+...@googlegroups.com>.
> To post to this group, send email to sqlal...@googlegroups.com
> <mailto:sqlal...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

Jothybasu Selvaraj

unread,
Dec 3, 2015, 5:52:50 PM12/3/15
to sqlal...@googlegroups.com
Thanks, I will give it a try.

Cheers

Jothy

You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/aii1o5rV8o8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages