Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7363 มุมมอง

How to Fetch data from Mysql and put into Postgressql using Server Action.

eg.select data from the mysql tables and copy into postgressql table.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

hello..

first you have to install pymssql...(pip install pymssql)

Then create one server action by below python code:

conn = pymssql.connect(server=your_obj.url, port=your_obj.port_no, user=your_obj.user_name,password=your_obj.password, database=your_obj.database_name)

cur = conn.cursor()

cur.execute("SELECT col_name from your_table")



Thank You

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hey Vijay,

You need to import pymysql.

after this for connectivity.

def connection(self):

        hostname = self.host_name

        password = self.password

        dbname = self.db_name

        dbusername = self.db_user

        try:

            if self.connector == 'mysql':

                db_connection = pymysql.connect(

                    hostname, dbusername, password, dbname)

                cursor = db_connection.cursor()
                #For Query 

                cursor.execute("show tables;")

                datas = cursor.fetchall()

        # If connection is not successful

        except:

            self.env.user.notify_warning(message='Connection Failed !')

            return 0

        self.env.user.notify_success(message='Connection Successful !')


I Hope it will Useful for you.


อวตาร
ละทิ้ง

This code work for you ?

Related Posts ตอบกลับ มุมมอง กิจกรรม
[Odoo V8] Server Actions แก้ไขแล้ว
1
ก.ค. 15
4544
0
มี.ค. 25
1296
0
ม.ค. 25
3406
2
ส.ค. 24
1452
0
ม.ค. 25
1337