Questions tagged [pandas-to-sql]

Pandas DataFrame method that writes the object's records to a SQL database. Be sure to also include the [pandas] tag.

Pandas DataFrame method to_sql can be used to write its records to a SQL database.

The documentation:

144 questions
0
votes
1 answer

pandas to_sql only writing first row to db

I am using the below code to read a tab delimited file into a postgres database enginestring = cfg.dbuser+":"+cfg.dbpwd+"@"+server.local_bind_host+":"+str(server.local_bind_port)+"/"+cfg.dbname engine = create_engine('postgresql://' +…
gkennos
  • 371
  • 4
  • 14
0
votes
0 answers

How to escape '(' in SQL SERVER tables column names while using pandas to_sql?

I'm facing below error while using pandas to_sql for entering data into my SQL SERVER database: ERROR: (pymssql.ProgrammingError) (102, b"Incorrect syntax near '('.DB-Lib error message 20018, severity 15:\nGeneral SQL Server error: Check …
Sumit Pandey
  • 448
  • 2
  • 9
0
votes
0 answers

Uploading emojis as NVARCHAR to MSSQL eats up characters at end of data field

SCENARIO: I'm using Pandas.to_sql() with parameter dtype={'COLUMN': NVARCHAR} to upload COLUMN containing text with emojis to a MSSQL DB via FreeTDS. NVARCHAR is imported from sqlalchemy.types import NVARCHAR. The COLUMN is fed as a DataFrame from…
0
votes
0 answers

Why such a big difference about the speed of insert data to PostgreSQL with the same codes and same computer?

I use pandas.to_sql() to insert a dataframe to PostgreSQL. When i run the codes in localhost and the database also in localhost, it cost about 5 mins to finish. But when the codes and database were not in the same computer, it costs about 40 mins…
0
votes
0 answers

Pandas 'Incorrect information in file' using to_sql Method

I have a pandas dataframe and am writing to a SQL database via this code: df.to_sql(con=conn, name='temp', if_exists='replace',index=False) It throws the following error. I'm wondering what this error means, why its getting displayed, and how do I…
Jason Melo Hall
  • 652
  • 2
  • 11
  • 23
0
votes
1 answer

Sorting and loading data from Pandas to Redshift using to_sql

I've built some tools that create front-end list boxes for users that reference dynamic Redshift tables. New items in the table, they appear automatically in the list. I want to put the list in alphabetical order in the database so the dynamic list…
dataflux
  • 7
  • 1
  • 4
0
votes
0 answers

Load a dataframe to SQL Server from pandas?

I am trying to test a script that will push a dataframe to SQL Server. Here is what I have so far: import pandas as pd import pyodbc conn_str = ( r'Driver={SQL Server};' r'SERVER=wouldntuliketoknow\SQLEXPRESS;' r'Database=test;' …
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
0
votes
1 answer

Load Pandas DataFrame to MS SQL localhost DB

I am trying to load data frame 'f3' to MS SQL server running in localhost with the help of python script. Here is my code; import sqlalchemy import pyodbc engine = sqlalchemy.create_engine("mssql+pyodbc://localhost/test_project") f3.to_sql("test",…
Ishwor Bhatta
  • 139
  • 1
  • 3
  • 13
-1
votes
2 answers

python dataframe to_sql with different schema

I want to store a dataframe into an existing MSSQL table. Dataframe has 3 columns, but the SQL table has only 2. How is it possible to store the 2 columns with the same name into SQL? I tried the following code: df.to_sql(sTable, engine,…
Wst
  • 11
  • 3
1 2 3
9
10