odino / docsql

Import Google Docs' spreadsheets into a MySQL table

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Archive tables never purged

mansj opened this issue · comments

commented

Hi there, first of all - thank you so much for developing this software, it was exactly what I was looking for, and works like a charm.

I can't seem to get the archived tables to be deleted. I've experimented with different settings for -k (--keep) but none are deleted, even though command-line output seems to claim it is doing so:

2019/03/20 16:06:05 Connecting to MySQL... 2019/03/20 16:06:05 Clearing old tables... 2019/03/20 16:06:05 All done

The user has DROP privileges.

Hey @mansj happy to hear you're finding this useful!

The problem seems very weird! Can you try running the following query with the parameters you pass to docsql:

SELECT table_name FROM information_schema.tables where table_schema='%s' AND table_name LIKE \"%s_%%_archive\" ORDER BY table_name DESC LIMIT 10000 OFFSET %d"

(you'll need db, table, keep)

I suspect no tables are found here, thus they don't get deleted.

commented

Thank you. I see a problem with the SQL you sent. There's a double '%' in the middle, right?

table_name LIKE \"%s_%%_archive\" should probably be table_name LIKE \"%s_%_archive\"

If I change that on my end when running the query manually (also omitting the OFFSET and the table_schema, which I don't know what needs to be filled in) the result works.

The double % will be converted to a single % when Go formats our query, so that shouldn't be a problem (playground).

Schema is the name of your database, offset is the number of tables you want to preserve.

commented

I see. In that case, the line seems to work as it is, because it returns all the archive tables, at the moment 117 of them in my database.

Here's the full line I'm running now:

SELECT table_name FROM information_schema.tables where table_schema='dm_stripped' AND table_name LIKE "dm_songs_%_archive" ORDER BY table_name DESC LIMIT 10000 OFFSET 10;

commented

I also attempted to manually issue a "DROP TABLE" command as the user in question, and managed to drop an archive table no problem.