Created
November 15, 2011 18:00
-
-
Save dckc/1367801 to your computer and use it in GitHub Desktop.
why am I getting: sqlalchemy.exc.CompileError: The version of oracle you are using does not support empty inserts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
import logging | |
import sqlalchemy | |
def main(): | |
logging.basicConfig(level=logging.DEBUG, stream=sys.stderr) | |
sl = logging.getLogger('sqlalchemy') | |
sl.setLevel(logging.DEBUG) | |
schemaname, tablename, infn, dbaddr = sys.argv[1:5] | |
rows = csv.DictReader(open(infn)) | |
e = sqlalchemy.create_engine(dbaddr) | |
# print e.execute('select 1+1 from dual').fetchall() | |
md = sqlalchemy.MetaData(e) | |
t = sqlalchemy.Table(tablename, md, schema=schemaname, autoload=True) | |
conn = e.connect() | |
conn.begin() | |
for row in rows: | |
conn.execute(t.insert(values=row)) | |
conn.commit() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
because there is no intersection between
t.insert().compile().params
(lowercase) androws.fieldnames
(uppercase?).