charset parameter mssql_db module

23 views
Skip to first unread message

Rafael Oliveira

unread,
Apr 29, 2020, 11:53:36 AM4/29/20
to Ansible Project
Hello everyone,

If possible, how can I set the charset parameter to mssql_db module?


In python I can do something like that:
conn = pymssql.connect(server, user, password, db_name, charset='WINDOWS-1252')

KR,
Rafael

Kai Stian Olstad

unread,
Apr 29, 2020, 3:04:42 PM4/29/20
to ansible...@googlegroups.com
On Wed, Apr 29, 2020 at 08:53:35AM -0700, Rafael Oliveira wrote:
> If possible, how can I set the charset parameter to mssql_db module?

I guess you could but the create table statement in a file and point target to
it with state: import.

--
Kai Stian Olstad

Rafael Oliveira

unread,
Apr 29, 2020, 3:31:22 PM4/29/20
to Ansible Project
I'm sorry I don't know if I got your point, nevertheless let me break down my situation: 

I already have DB structure where those a lot of tables were created with German UMLAUT öäüÜÖÄ.

From time to time I have to run some scripts to maintain these tables, I'd like to automate this script execution so I created the following task:


nameRun script
  mssql_db:
    name"{{ DB_NAME }}"
    login_host"{{ DB_HOST }}"
    login_user"{{ DB_USER }}"
    login_password"{{ DB_PASS }}"
    stateimport
    target"{{ SCRIPT_PATH }}"

The step before that is SVN Checkout, as you can see I'm running a script in the import state, how should I change my script, that's the point that I could not understand.

Thanks in advance for your support.

KR,
Rafael

Kai Stian Olstad

unread,
Apr 30, 2020, 5:25:16 AM4/30/20
to ansible...@googlegroups.com
On Wed, Apr 29, 2020 at 12:31:21PM -0700, Rafael Oliveira wrote:
> I'm sorry I don't know if I got your point, nevertheless let me break down
> my situation:
>
> I already have DB structure where those a lot of tables were created with
> German UMLAUT ЖДЭэжд.
>
> From time to time I have to run some scripts to maintain these tables, I'd
> like to automate this script execution so I created the following task:
>
>
> - name: Run script
> mssql_db:
> name: "{{ DB_NAME }}"
> login_host: "{{ DB_HOST }}"
> login_user: "{{ DB_USER }}"
> login_password: "{{ DB_PASS }}"
> state: import
> target: "{{ SCRIPT_PATH }}"
>
> The step before that is SVN Checkout, as you can see I'm running a script
> in the import state, how should I change my script, that's the point that I
> could not understand.

Every MySQL command that support charset like alter/create database you can add
charset=<> to it, check the MySQL documentation on how.

But if you do a "ansible-doc mysql_db" you'll see that it has an encoding option.

- encoding
Encoding mode to use, examples include `utf8' or `latin1_swedish_ci'
[Default: (null)]

After looking at the source code, this option has been there since before 2014
but the online documentation doesn't show it and several other options.

--
Kai Stian Olstad

Rafael Oliveira

unread,
Apr 30, 2020, 8:58:35 AM4/30/20
to ansible...@googlegroups.com
But I'm using mSsql_db

☹️

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20200430092457.dsm6r6pg5lfk4pb3%40olstad.com.

Kai Stian Olstad

unread,
May 2, 2020, 4:52:21 AM5/2/20
to ansible...@googlegroups.com
On Thu, Apr 30, 2020 at 09:58:07AM -0300, Rafael Oliveira wrote:
> But I'm using mSsql_db

That makes a huge difference, sorry I misread.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages