Question

CSV Import through PGAdmin Not working, alternate options?

Hello,

We wish to import data in a table from a csv. The copy command fails as super user permissions are not there. I have raised a ticket. But the issue is not resolved yet.

Are there any easy tools or any other options by which this can be executed? Copy data in a csv nia table.

regards


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

Indeed, uploading a file directly to a managed database is quite likely not going to work with the default permissions.

What I could suggest is to use a script to do the import. For example, you could use the following Python script to do the import:

import pandas as pd

df = pd.read_csv('/path/to/your.csv')
df.columns = [c.lower() for c in df.columns] # PostgreSQL doesn't like capitals or spaces

from sqlalchemy import create_engine
engine = create_engine('postgresql://username:password@localhost:5432/dbname')

df.to_sql("my_table_name", engine)

Make sure to change the connection string and the table name.

Best,

Bobby