unable to sync local sqlite with postgres table does not have any primary key #1226
Replies: 2 comments 4 replies
-
Weird, it's working for me ... here is the code I used: Creating the database on PostgreSQLcreate schema dataengine;
create table dataengine.trackplot_cog (
gid serial primary key,
id integer,
"timestamp" timestamp,
name character varying(255),
lat numeric (38,8),
long numeric (38,8)
);
Making a sync (that will create automatically the SQLite database):var serverProvider = new NpgsqlSyncProvider(DBHelper.GetNpgsqlDatabaseConnectionString("data"));
var clientProvider = new SqliteSyncProvider(Path.GetRandomFileName().Replace(".", "").ToLowerInvariant() + ".db");
var setup = new SyncSetup("dataengine.trackplot_cog");
var options = new SyncOptions();
options.DisableConstraintsOnApplyChanges = true;
var progress = new SynchronousProgress<ProgressArgs>(s =>
Console.WriteLine($"{s.ProgressPercentage:p}: " +
$"\t[{s?.Source?[..Math.Min(4, s.Source.Length)]}] {s.TypeName}: {s.Message}"));
do
{
try
{
Console.ForegroundColor = ConsoleColor.Green;
var s = await agent.SynchronizeAsync(scopeName, setup, progress:progress);
Console.WriteLine(s);
}
catch (SyncException e)
{
Console.ResetColor();
Console.WriteLine(e.Message);
}
catch (Exception e)
{
Console.ResetColor();
Console.WriteLine("UNKNOW EXCEPTION : " + e.Message);
}
Console.WriteLine("--------------------");
}
while (Console.ReadKey().Key != ConsoleKey.Escape); QuestionsWhat PostgreSQL version are you using ? For your specific error, DMS is using this query to get all the primary keys: SELECT CCU.COLUMN_NAME,
TC.CONSTRAINT_NAME,
C.ORDINAL_POSITION
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS CCU ON CCU.CONSTRAINT_SCHEMA = TC.CONSTRAINT_SCHEMA
AND CCU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME
JOIN INFORMATION_SCHEMA.COLUMNS AS C ON C.TABLE_SCHEMA = TC.CONSTRAINT_SCHEMA
AND TC.TABLE_NAME = C.TABLE_NAME
AND CCU.COLUMN_NAME = C.COLUMN_NAME
WHERE TC.CONSTRAINT_TYPE = 'PRIMARY KEY'
AND TC.TABLE_NAME = 'trackplot_cog'
AND TC.TABLE_SCHEMA = 'dataengine'; Is it working for you ? |
Beta Was this translation helpful? Give feedback.
-
edit: postgres version "server_version" "16.3"
end edit thanks for the quick and clear response. the issue that I am encountering is indeed quite strange.
my result is
but if I apply the code you posted which is in the method to check the prim key for dotmim sync
result is after some debugging it seems that the problem could be due to this
as you can imagine I am not a database expert. I wonder if this is a bug of dotmim sync or an underlying structural problem of my postgres database implementation. I will contact the admin and ask to manually reset the prim key
and post an update here |
Beta Was this translation helpful? Give feedback.
-
I'm attempting to synchronize a SQLite database with a PostgreSQL database using Dotmim.Sync. Here are the details of my setup:
Database Providers:
Synchronization Method:
I'm initiating the sync process using the following code:
Error:
Dotmim.Sync is unable to detect the primary key in the dataengine.trackplot_cog table, despite both tables having a primary key defined on the gid column.
Why is Dotmim.Sync failing to recognize the primary key in my PostgreSQL table?
Are there any additional configuration steps I need to take to ensure proper primary key detection?
Could there be any issues with schema detection or naming conventions that I'm overlooking?
Beta Was this translation helpful? Give feedback.
All reactions