Open sanghunka opened 7 years ago
the 'conn' in df.to_sql is sqlalchemy engine. As explained at https://github.com/cloudera/impyla/issues/214, you can try this
im using pymysql for the connection with the db as I have the server credentials. can I use sqlalchemy with it?
import pandas as pd try: mydb = connection.connect(host="localhost",database="student",user="root",passwd="manav",use_pure=True) print(mydb.is_connected()) q = "CREATE TABLE STUDENT_INFO(SID INT AUTO_INCREMENT PRIMARY KEY,STUDENT_FIRST_NAME VARCHAR(30),STUDENT_LAST_NAME VARCHAR(30),"\ "STUDENT_REGISTRATION_DATE DATE,STUDENT_CLASS VARCHAR(20),STUDENT_SECTION VARCHAR(20))" cur = mydb.cursor() cur.execute(q) print("Table is Created!...") mydb.close() except Exception as e: print(str(e))
mydb = connection.connect(host="localhost",database="student",user="root",passwd="manav",use_pure=True) stud_data = pd.read_csv("stud_data.csv") stud_data
stud_data1 = pd.read_sql("SELECT * FROM STUDENT_DETAILS",mydb) stud_data1
stud_data1.to_sql('STUDENT_INFO',con = mydb)
ProgrammingError Traceback (most recent call last) ~\anaconda3\lib\site-packages\pandas\io\sql.py in execute(self, *args, *kwargs) 1680 try: -> 1681 cur.execute(args, **kwargs) 1682 return cur
~\anaconda3\lib\site-packages\mysql\connector\cursor.py in execute(self, operation, params, multi) 558 if psub.remaining != 0: --> 559 raise errors.ProgrammingError( 560 "Not all parameters were used in the SQL statement")
ProgrammingError: Not all parameters were used in the SQL statement
The above exception was the direct cause of the following exception:
DatabaseError Traceback (most recent call last)
This is my code there having the same error can anyone ping me to solve this error
same error here, python 3.8.10 pandas 1.3.3 sqlalchemy 1.4.25
same error here, python 3.8.10 pandas 1.3.3 sqlalchemy 1.4.25
There May be some version error update the version then check it it will be come or not
For me, this same message meant I had lost the database connection.
I'm also blocked by this error. Upgrading to snowflake-connector 2.8.2 (the latest) did not solve it.
+1
I installed hadoop, hive, hiveserver2 on my local mac. I can create hive engine. With this engine, i can use pandas read_sql(). but i can't use to_sql() though both method use same engine object.
In my opinion, there is parsing error while handling parameters.
Below is full error messages.
Thank you for this cool project
impyla