Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Best way to mass import links?

    Kutt
    3
    4
    31
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ajtatum
      ajtatum last edited by

      I have exported all my Bitly links and was curious what the best way to import ~2k records would be. There's an API call for creating one URL at a time... so I could loop through them with some pacing in between, but was curious if it's possible to access Kutt's database directly and import them that way... or if that's more trouble then it's worth.

      Any thoughts would be appreciated!

      martinkbs girish 2 Replies Last reply Reply Quote 0
      • martinkbs
        martinkbs @ajtatum last edited by

        Hi @ajtatum,

        For me the fastest way is to create a workflow in n8n that will loop through all the addresses in a list, and for each one of them, make an HTTP Request to create the shortened link in Kutt.

        😉

        1 Reply Last reply Reply Quote 2
        • girish
          girish Staff @ajtatum last edited by

          @ajtatum From my quick testing, there is just a table called links. Might be easy to script this.

           id | address | description | banned | banned_by_id | domain_id | password | expire_in |       target        | user_id | visit_count |          created_at           |          updated_at           |                 uuid                 
          ----+---------+-------------+--------+--------------+-----------+----------+-----------+---------------------+---------+-------------+-------------------------------+-------------------------------+--------------------------------------
            1 | iL6uu0  |             | f      |              |           |          |           | https://cloudron.io |       2 |           0 | 2022-12-12 12:06:41.689773+00 | 2022-12-12 12:06:41.689773+00 | 65320acc-e34e-4341-8c35-2bdfd898c9d9
          
          1 Reply Last reply Reply Quote 0
          • girish
            girish Staff last edited by

            Further....

            db81c034f66d9c4cc29c7811bb89b95f24=> \d links
                                                    Table "public.links"
                Column    |           Type           | Collation | Nullable |              Default              
            --------------+--------------------------+-----------+----------+-----------------------------------
             id           | integer                  |           | not null | nextval('links_id_seq'::regclass)
             address      | character varying(255)   |           | not null | 
             description  | character varying(255)   |           |          | 
             banned       | boolean                  |           | not null | false
             banned_by_id | integer                  |           |          | 
             domain_id    | integer                  |           |          | 
             password     | character varying(255)   |           |          | 
             expire_in    | timestamp with time zone |           |          | 
             target       | character varying(2040)  |           | not null | 
             user_id      | integer                  |           |          | 
             visit_count  | integer                  |           | not null | 0
             created_at   | timestamp with time zone |           | not null | CURRENT_TIMESTAMP
             updated_at   | timestamp with time zone |           | not null | CURRENT_TIMESTAMP
             uuid         | uuid                     |           | not null | uuid_generate_v4()
            Indexes:
                "links_pkey" PRIMARY KEY, btree (id)
            Foreign-key constraints:
                "links_banned_by_id_foreign" FOREIGN KEY (banned_by_id) REFERENCES users(id)
                "links_domain_id_foreign" FOREIGN KEY (domain_id) REFERENCES domains(id)
                "links_user_id_foreign" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
            Referenced by:
                TABLE "visits" CONSTRAINT "visits_link_id_foreign" FOREIGN KEY (link_id) REFERENCES links(id) ON DELETE CASCADE
            

            So, then, I tried

            db81c034f66d9c4cc29c7811bb89b95f24=> INSERT INTO links (address, target, user_id) VALUES ('x1234', 'https://blog.cloudron.io', 2);
            INSERT 0 1
            

            Visiting x1234 redirects properly. So, quite easy to script this. Note that 2 is the user id, might have to check the db what the user id is in your case.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB