I am using the following code to upload a df as in a db
link=('postgresql://'+user_name+':'+password+'#'+host_name+':5432/postgres')
engine=create_engine(link)
I would love to write this df in a selected schema and not in the public schema. How can I do it?
Related
Is there a query in UCANACCESS database that creates a non existing database ?
I'm trying to write a statement that creates a new access database using JDBC.
Sql and MySql database creation queries are something like this "CREATE DATABASE database_name"
but trying to write this statement in "ucanaccess" gets an error as the word "DATABASE" is not recognized.
We are writing a new application, and while testing, we will need a bunch of dummy data. I've added that data by using MS Access to dump excel files into the relevant tables into the Postgres database.
What should I do now to generate an Insert statements from the PGAdmin4 Tool similar to what SQL Studio allow us to generate an Insert statements for SQL Server? There are no options available to me. I can't use the closest one, which is to export and import the data via CSV.
I understand that you cannot import the CSV file into the actual DB as this needs to be done through ASP.NET core EF. Perhaps, you can probably create a test schema and import the CSV file into the test schema. Once you have the data imported into the test schema, you can use that to generate SQL statements using the steps below:
Right click on target table and select "Backup".
Select a file path to store the backup. You can save the file name as data.backup
Choose "Plain" as Format.
Open the tab "Options" check "Use Column Inserts".
Click the Backup-button.
Once the file gets generated you can open with Notepad++ or VSCode to get the SQL insert statements
You can use the statements generated and delete the test schema created
Here is a resource that might help you in loading data from Excel file into PostgresSQL if you still need to take this path Transfer Data from Excel to PostgreSQL
I have three postgresql databases in a server: db1,db2,db3. Now I want to save the tables in each db to a new db dbnew and distinguish it with schemas. Which means that there are three schemas in this database dbnew.db1,dbnew.db2,dbnew.db3. What is the easiest method to realize it?
(p.s.: I have dumped the database to local files.)
I test the answer from #a_horse_with_no_name, it seems to work but there is a new problem as follows:
If in db1 there is an extension like postgis, then I load db1 with psql and rename public to db1 and create a new schema named public. I could not create the extension postgis for public schema as it shows that extension postgis already exists. However if I use the command \dx, it shows that the extension is in schema db1 not in dbnew. Even if I use create EXTENSION postgis with schema public it doesn't work.
Based on backup/plain and restore using psql
I assume, that the schemas in dbnew are created and the rights to schema are set to the user doing all restoring using psql.
Somehow create sql files (backup plain in pgadmin3), the resulting files can be loaded into the dbnew database using psql, but they should piped through sed or grep, so that all tablenames get the schema prefix.
With somehow I meant, backup from original or first restore your backups into a temporary db, if they are no sql yet, and backup them as plain text.
Assuming all tables are stored in the public schema in the source databases
Import the first dump (by running psql ... -f dumpfile.sql), then rename the public schema to the new name:
alter schema schema public rename to db1;
Then re-create the public schema:
create schema public;
Now do the same thing for the other two database scripts.
I have an excel file and I have to load the excel data into SQL tables through an SSIS package.
I have tried creating a package and added excel connection manager and excel source but the excel is showing up an error and name of the excel sheet in the drop down is not loading...
Please help. Let me know if you need any further information. Thanks!
Apparently it is not possible to connect to a pw protected excel file even though there is that property:
https://msdn.microsoft.com/en-us/library/ms139836.aspx
I did find a workaround though using powershell to open and save as...
http://www.sqlservercentral.com/Forums/Topic885800-148-1.aspx
In my cocoa application, I am including a SQLite3 db. General process is:
I check if database with same name exists in Documents folder.
If it does not exist I copy it from application binary to Documents folder.
My question is:
Can we directly create db via code, if
it does not exist.. something like
create db xyz ?
Thanks,
Miraaj