· 8 years ago · Jun 12, 2018, 06:56 PM
1#CONNECTION TO SQL DATABASE
2db=sql.connect(host="localhost",user="root",passwd="hrithiK@860",db="nightsky")
3cur=db.cursor()
4#CONVERTING DATAFRAME(df_final) INTO TABLE
5df_final.to_sql(con=db, name='finaltable', if_exists='replace', chunksize=5000)
6
7Traceback (most recent call last):
8File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesM
9ySQLdbcursors.py", line 238, in execute
10query = query % args
11TypeError: not all arguments converted during string formatting
12
13During handling of the above exception, another exception occurred:
14
15Traceback (most recent call last):
16File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
17andasiosql.py", line 1400, in execute
18cur.execute(*args)
19File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesM
20ySQLdbcursors.py", line 240, in execute
21self.errorhandler(self, ProgrammingError, str(m))
22File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesM
23ySQLdbconnections.py", line 52, in defaulterrorhandler
24raise errorclass(errorvalue)
25_mysql_exceptions.ProgrammingError: not all arguments converted during string fo
26rmatting
27
28During handling of the above exception, another exception occurred:
29
30Traceback (most recent call last):
31File "pt.py", line 77, in <module>
32df_final.to_sql(con=db, name='finaltable', if_exists='replace', chunksize=50
3300)
34File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
35andascoregeneric.py", line 2127, in to_sql
36dtype=dtype)
37File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
38andasiosql.py", line 450, in to_sql
39chunksize=chunksize, dtype=dtype)
40File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
41andasiosql.py", line 1502, in to_sql
42table.create()
43File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
44andasiosql.py", line 561, in create
45if self.exists():
46File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
47andasiosql.py", line 549, in exists
48return self.pd_sql.has_table(self.name, self.schema)
49File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
50andasiosql.py", line 1514, in has_table
51return len(self.execute(query, [name, ]).fetchall()) > 0
52File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
53andasiosql.py", line 1412, in execute
54raise_with_traceback(ex)
55File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
56andascompat__init__.py", line 403, in raise_with_traceback
57raise exc.with_traceback(traceback)
58File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesp
59andasiosql.py", line 1400, in execute
60cur.execute(*args)
61File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesM
62ySQLdbcursors.py", line 240, in execute
63self.errorhandler(self, ProgrammingError, str(m))
64File "C:UsersDELLAppDataLocalProgramsPythonPython36libsite-packagesM
65ySQLdbconnections.py", line 52, in defaulterrorhandler
66raise errorclass(errorvalue)
67pandas.io.sql.DatabaseError: Execution failed on sql 'SELECT name FROM
68sqlite_ma
69ster WHERE type='table' AND name=?;': not all arguments converted during string
70formatting