Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6001525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:50:49+00:00 2026-05-23T00:50:49+00:00

This is my code below and I try to load data from one database

  • 0

This is my code below and I try to load data from one database to another. I believe everything works fine but an error occurs and I don’t know what this means.

import pymssql, psycopg2

class Datenbankabfrage:

def __init__(self):
    self.conn1 = pymssql.connect(host='***', user='***', password='***', database='****')
    self.conn2 = psycopg2.connect("dbname='****' user='****' host='****' password='****'")

    self.cur1 = self.conn1.cursor()
    self.cur2 = self.conn2.cursor()

def abfrage(self):
    self.cur1.execute("SELECT tag, site, plant, unit, line, ProcessID AS pid, Count(ReadTime) AS mods \
                        FROM ( \
                        select dateadd(dd, -1, convert(varchar, getDate(),111)) \
                        as tag, ReadTime, processID, subid, PR.Site, PR.Plant, PR.Unit, PR.Line \
                        from FactBarcodeReading BCR with(nolock) \
                        inner join DimProcess PR on BCR.ProcessKey = PR.ProcessKey \
                        where PR.ProcessID IN  (802, 1190, 1800, 3090, 3590, 4390, 4590, 4800, 5000, 5400, 4190) \
                        and ReadTime between dateadd(dd, -1, convert(varchar, getDate(),111)) \
                        and dateadd(dd, -0, convert(varchar, getDate(),111)) \
                        ) a \
                        GROUP BY tag, site, plant, unit, line, ProcessID \
                        ORDER BY site, plant, unit, line, ProcessID")

    self.rows = self.cur1.fetchall()

    query = ("INSERT INTO '20091229global' (proddate, site, plant, unit, line, pid, mods) VALUES (?, ?, ?, ?, ?, ?, ?)", self.rows)

    self.cur2.executemany(query)

    self.conn2.commit()

    self.conn2.close()



a = Datenbankabfrage()
a.abfrage()

This is the error:

Traceback (most recent call last):
File "C:\Documents and Settings\FS107319\My Documents\Python\mssql_abfrage.py", line 39, in <module>
a.abfrage()
File "C:\Documents and Settings\FS107319\My Documents\Python\mssql_abfrage.py", line 30, in    abfrage
self.cur2.executemany(query)
TypeError: Required argument 'vars_list' (pos 2) not found

————————————————————————

Ok here is my edit:

Now, this is my new code

query("INSERT INTO '20091229global' (proddate, site, plant, unit, line, pid, mods) VALUES ('?', '?', '?', '?', '?', '?', '?')")

self.cur2.execute(query, self.rows)

sorry the error before occured was wrong because i forgot the “=” behind query
that’s the real error

Traceback (most recent call last):
File "C:\Documents and Settings\FS107319\My Documents\Python\mssql_abfrage.py", line 39, in <module>
a.abfrage()
File "C:\Documents and Settings\FS107319\My Documents\Python\mssql_abfrage.py", line 30, in abfrage
self.cur2.execute(query, self.rows)
ProgrammingError: FEHLER:  Syntaxfehler bei »'20091229global'«
LINE 1: INSERT INTO '20091229global' (proddate, site, plant, unit, l...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:50:49+00:00Added an answer on May 23, 2026 at 12:50 am

    According to the documentation, executemany() takes two parameters. You have provided but one (query).

    executemany(operation, seq_of_parameters)

    Prepare a database operation (query or
    command) and then execute it against
    all parameter tuples or mappings found
    in the sequence seq_of_parameters.

    The function is mostly useful for
    commands that update the database: any
    result set returned by the query is
    discarded.

    Parameters are bounded to the query
    using the same rules described in the
    execute() method.

    Perhaps you just want execute()?

    Or, more likely:

    query = "INSERT INTO '20091229global' (proddate, site, plant, unit, line, pid, mods) VALUES (?, ?, ?, ?, ?, ?, ?)"
    self.cur2.executemany(query, self.rows)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
Basically this code below returns the right information, but I need to add the
i want to put the id into the colorbox below this code nom works
This code below is for executing ls -l | wc -l. In the code,
i am using this code below to dynamically capture the name of the button
I have this code below. As you can see I am passing two variables
Hi I'm using this code below to let a user draw their signature on
How can this code compile? The code below in the operator int CAN access
I have this javascript code below that uses jquery, it is suppoed to be
I ended up with this horrible code below, I can't get a better result

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.