I am trying to move my PostgreSQL database with all the data inside it to a MySQL database so I am using MySQL Workbench > Data migration tool.
On the "Reverse Engineer Source" step I got a strange error:
ERROR: Reverse engineer selected schemata: ProgrammingError("('42P01', '[42P01] ERROR: relation "public.psqlcfg_lid_seq" does not exist;\nError while executing the query (7) (SQLExecDirectW)')"): error calling Python module function DbPostgresqlRE.reverseEngineer Failed
The complete error log where this error message appears at its end is:
Starting...
Connect to source DBMS...
- Connecting...
Connecting to ...
Opening ODBC connection to DSN=InventoryDBDS...
Connected
Connect to source DBMS done
Reverse engineer selected schemata....
Reverse engineering public from InventoryDB
- Reverse engineering catalog information
Traceback (most recent call last):
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\db_postgresql_re_grt.py", line 335, in reverseEngineer
return PostgresqlReverseEngineering.reverseEngineer(connection, catalog_name, schemata_list, context)
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\db_generic_re_grt.py", line 228, in reverseEngineer
catalog = cls.reverseEngineerCatalog(connection, catalog_name)
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\db_generic_re_grt.py", line 388, in reverseEngineerCatalog
cls.reverseEngineerSequences(connection, schema)
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\db_postgresql_re_grt.py", line 76, in reverseEngineerSequences
min_value, max_value, start_value, increment_by, last_value, is_cycled, ncache = cls.execute_query(connection, seq_details_query % (schema.name, seq_name)).fetchone()
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\db_generic_re_grt.py", line 76, in execute_query
return cls.get_connection(connection_object).cursor().execute(query, *args, **kwargs)
pyodbc.ProgrammingError: ('42P01', '[42P01] ERROR: relation "public.psqlcfg_lid_seq" does not exist;\nError while executing the query (7) (SQLExecDirectW)')
Traceback (most recent call last):
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\workbench\wizard_progress_page_widget.py", line 192, in thread_work
self.func()
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\migration_schema_selection.py", line 160, in task_reveng
self.main.plan.migrationSource.reverseEngineer()
File "C:\Program Files\MySQL\MySQL Workbench CE 6.0.6\modules\migration.py", line 335, in reverseEngineer
self.state.sourceCatalog = self._rev_eng_module.reverseEngineer(self.connection, self.selectedCatalogName, self.selectedSchemataNames, self.state.applicationData) SystemError: ProgrammingError("('42P01', '[42P01] ERROR: relation "public.psqlcfg_lid_seq" does not exist;\nError while executing the query (7) (SQLExecDirectW)')"): error calling
Python module function DbPostgresqlRE.reverseEngineer
ERROR: Reverse engineer selected schemata: ProgrammingError("('42P01', '[42P01] ERROR: relation "public.psqlcfg_lid_seq" does not exist;\nError while executing the query (7) (SQLExecDirectW)')"): error calling Python module function DbPostgresqlRE.reverseEngineer Failed
I've searched the web for anything related to (error 42P01) appearing in the log, but couldn't find any reference. So if someone can please tell me what exactly I am doing wrong here that will be really great.
Thanks
This error bring me here.
If your "psqlcfg_lid_seq" actually including both uppercase and lowercase character(s), remember that PostgreSQL will convert the name into ALL lowercase for query.
A basic knowledge is: In order to perform a case matched query, the name must be wrapped by double quotation marks ("), so the convertion will be avoided.
However, in MySQL Workbench, they forget to do that when try to fetch sequences.
In db_postgresql_re_grt.py. Located in %Program Files%\MySQL\MySQL Workbench (Your version, for example "6.1 CE")\modules on Windows.
Line around 70, you will found the SQL query in the variable seq_details_query, it will be something like:
seq_details_query = """SELECT min_value, max_value, start_value,
increment_by, last_value, is_cycled, cache_value
FROM %s.%s"""
Change that to:
seq_details_query = """SELECT min_value, max_value, start_value,
increment_by, last_value, is_cycled, cache_value
FROM \"%s\".\"%s\""""
So the sequences can be fetched, and so whole flow can be proceed.
Notice that: You may need to restart MySQL Workbench to use modified scripts.
I'm surprised MySQL guys still not fix this problem. Maybe i need report the bug somehow? :P
42P01 is a generic error meaning the object doesn't exist.
In this case it's the sequence public.psqlcfg_lid_seq that does not exist.
Based on the series of error messages, the error happens when the tool tries to query the attributes of that sequence (with SELECT ... FROM schema_name.sequence_name)
Presumably this sequence is still referenced somewhere in the database even if ot no longer exists. In theory there are safeguards in PostgreSQL against this situation (dependency tracking) but I believe they depend on your server version and maybe on the specifics of the dependency.
To find the references to this sequence, one approach would be to dump the database schema to an SQL text file (with pg_dump -s) and search for the text psqlcfg_lid_seq within it.
Once found, presumably some ALTER statements may be able to remove the references.
Related
I am using SAS Studio (the browser version) instead of a desktop SAS program.
I am trying to read a .sas7bdat file that I have uploaded onto a folder on SAS Studio.
libname HW5 '~/home/xxxxxxxxxxxx/sasuser.v94/HW5';
DATA FILE1;
set HW5.orders;
RUN;
I get the error:
ERROR: File HW5.ORDERS.DATA does not exist.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FILE1 may be incomplete. When this step was stopped there
were 0 observations and 0 variables.
WARNING: Data set WORK.DISCOUNT_RET was not replaced because this step was stopped.
Here is the image of the folder:
https://ibb.co/hN83ua
I realize this is a simple error but I don't know how to fix it. Thanks! If nothing works, can i read this via infile?
Right click on the HW5 folder in the list on the left and select properties. This should show you the physical location for that folder. Copy it and paste it into your LIBNAME statement enclosed in quotes. Most likely the issue was your inclusion of the ~ in front of the path.
libname HW5 '/home/xxxxxxxxxxxx/sasuser.v94/HW5';
In Windows, I am trying to import a large SQL dump file (4.6 GB) into SQL Server 2008. Since it's a large file, I used
sqlcmd -S <SERVER-NAME\INSTANCE> -i C:\<path_to_SQL_file>.sql -o C:\<path_to_output_file_1.txt
However, the command produces the following error:
Error: Syntax error at line 11302 near command '-' in file C:\.sql
In Mac OS X, sed -n '11302p' C:\<path_to_SQL_file>.sql produces
?????$R?}D?XL?)?_K??h?l????????p?^?'?F1璨?¸??ωN?Q???흞????????+/??I?*5jE?1????f?`?nL_?~E?????^ap??Ht?2???g
?2z7$(f???*??????C?????????A?K?хl?B?#??˞K?
q??z?
??I.?
^ ?ݢ?G??cu?Zc?t?'?&L?W??s???W\|x??^_??PǴb???F???m:RY?ES??-D??L?????n??'
3???+?ecKd?vysEkz???wh~;o7?y??\??i
I tried to inspect the file by splitting it using split command but the output is garbled.
Do you think the file is wrongly encoded? How do you feel I should proceed trying to find the error?
The dump file was earlier used by another developer who didn't have any problems with it. Unfortunately, he is on extended vacation for the time being.
I am trying to bulk insert some data from a txt file and I am having a lot of trouble. Whenever I try to do this I get the following error. Cannot bulk load because the file "H:\NAPApplication.txt" could not be opened. Operating system error code 3(The system cannot find the path specified.).
Here is the code I used for the bulk insert.
BULK
INSERT NAPApplication
FROM 'H:\NAPApplication.txt'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
);
I used Test-Path in Powershell to double check that the file exists where I say it does. I am confused why the path specified cannot be found if it is obviously there.
EDIT: SQL Server is on a different machine than the box that the file I am looking for is on. Is there anyway to tell the computer to look into my computer instead of the server?
The file needs to be in a location that the SQL Server can see. It cannot see your H: drive unless it is shared. Yoiu would then probably have to reference it by its UNC path. Can you not use a network share?
So we use osql to run in stored procedures as part of our build process. We use a project with an sp folder that gets published with applications as part of a build pack.
I used Visual Studio to create this project structure and created the sql scripts to run in the procs.
Visual Studio saved the files with UTF8 formatting (by default). osql when running in the scripts complained about every single script having a syntax error on line 1 i.e.
> Incorrect syntax near '´'. 1> 2> Msg 102, Level 15, State 1,
> Server GBEPIAP-SQL01, Line 1
Rather baffling.
Anyway; to fix the issue, the sql scripts could be saved with Unicode Codepage 1200 (File -> Advanced Save Options)
et voila - problem gone
Now that's left me with an even bigger problem; I have over 200 proc scripts that I need to open, change encoding and save with the new encoding.
Can any powershell guru do me up a quick script to change the encoding of every file in a folder to Unicode Codepage 1200? Would be doing me a favour while also saving time.
In the end I used the approach documented here
Save all files in Visual Studio project as UTF-8
But instead of UTF8; I specified Unicode.
foreach (var f in new DirectoryInfo(#"...").GetFiles("*.sql", SearchOption.AllDirectories)) {
string s = File.ReadAllText(f.FullName);
File.WriteAllText (f.FullName, s, Encoding.Unicode);
}
i have a big database dump (290mb). When i use import from cli everything is ok!
mysql -u root -piddqd whitestore_com < whitestore_com.sql
When i use the same command from bash script like:
./build.sh
Here is what i get:
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax
to use near 'mysql Ver 14.14 Distrib 5.1.66, for debian-linux-gnu (x86_64)
using readline 6.' at line 1
I dont know why I get this error, there is no such string as "mysql Ver 14.14 Distrib 5.1.66, for debian-linux-gnu (x86_64) in dump file
using readline 6."
Try opening up the whitestore_com.sql in a text editor and check the first couple of lines.
It looks like there's some text at the start of the .sql file that should be commented out.
It's opening up the mysql connection ok, but then the commands it's getting from whitestore_com.sql aren't valid SQL statements.