postgresql – Why doesn’t the $1 syntax work for all queries?

I tried to do this:

COPY postgres_log FROM $1 WITH csv;

And with a separately sent file path, like I make all normal queries (SELECT/UPDATE/INSERT/DELETE). However, it gives:

ERROR:  syntax error at or near "$1"

Um… So does that mean that I’m forced to send it a scary string like this?

COPY postgres_log FROM '/full/path/to/logfileblablabla.csv' WITH csv;

If so, why? Why don’t all query types support the parameterized queries interface? Isn’t this like asking to enable SQL query injection vulnerabilities?

python – SyntaxError: invalid syntax on lib/python3.8/site-packages/sql_server/pyodbc/base.py django deploy on Linux

**

  1. Preface (Testing HyperV Virtual Server with os: Ubuntu Server 20.04.1 on local Windows PC)

**

I am having problems deploying my Django app (using Python 3.8.2) on a Ubuntu Server 20.04.1 LTS that uses MS SQL Server as its database. No issues reverting back to ‘ENGINE’: ‘django.db.backends.sqlite3’ on Linux but I have to be honest, it is frustrating.

I already had to downgrade to Django==3.0 to get my app working on my local windows pc but the 2 migrations I did proves that I am missing something and I hope someone can give me a hand. Any help is appreciated.

  1. My PC

Working settings.py file (currently running on windows with Sql Server 2019 Express

    DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'mdm_db',
        'USER': 'AAA',
        'PASSWORD': 'AAA',
         'HOST': 'localhost\SQLEXPRESS',
        'PORT': '',

        'OPTIONS': {
            'driver': 'SQL Server Native Client 11.0',
            # 'driver': 'ODBC Driver 13 for SQL Server ', -> port 1433?
        },
    },
    }
installed components:
    pip freeze
    asgiref==3.2.10
    Django==3.0
    django-mssql-backend==2.8.1
    pyodbc==4.0.30
    pytz==2020.1
    sql-server.pyodbc==1.0
    sqlparse==0.3.1
  1. Ubuntu Server

(also tried using ODBC and installing the latest version https://docs.microsoft.com/it-it/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15)

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'mdm_db',
        'USER': 'mdmuser',
        'PASSWORD': 'mdmuser',
         'HOST': 'localhost\SQLEXPRESS',
        'PORT': '',
        'OPTIONS': {
            #'driver': 'SQL Server Native Client 11.0',
             'driver': 'ODBC Driver 17 for SQL Server ',
        },
    },
    }

Packages installed

:~/app/MDM_SQLServer$ history | grep install

   32  sudo apt-get install unixodbc-dev
   34  sudo apt-get install python3-dev
   36  sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
   60  sudo ACCEPT_EULA=Y apt-get install msodbcsql17
  1. Issue: (venv) luca@webserver:~/app/MDM_SQLServer$ python manage.py runserver

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception(1)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name(level:), package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/luca/app/MDM_SQLServer/cpus/models.py", line 6, in <module>
    from sites.models import Site
  File "/home/luca/app/MDM_SQLServer/sites/models.py", line 4, in <module>
    from wifis.models import Wifi
  File "/home/luca/app/MDM_SQLServer/wifis/models.py", line 3, in <module>
    class Wifi(models.Model):
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/db/models/base.py", line 121, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/db/models/base.py", line 325, in add_to_class
    value.contribute_to_class(cls, name)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/db/models/options.py", line 208, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/db/__init__.py", line 28, in __getattr__
    return getattr(connections(DEFAULT_DB_ALIAS), item)
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/db/utils.py", line 207, in __getitem__
    backend = load_backend(db('ENGINE'))
  File "/home/luca/app/venv/lib/python3.8/site-packages/django/db/utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name(level:), package, level)
  File "/home/luca/app/venv/lib/python3.8/site-packages/sql_server/pyodbc/base.py", line 7
    except ImportError, e:
                      ^
SyntaxError: invalid syntax

NOTE Prompt is not returned, I need to corntol+C out.

Thank you all.

MySQL: Why am I getting a syntax error when using the FIELDS ESCAPED BY clause on a select statement

I am attempting to generate a csv file including headers from a table in my MySQL 8.0 database. After a lot of searching I found the following suggest syntax:

    SELECT "ansId","assmt","ques","answerCode","details"
    FROM ayanswer
    UNION
    SELECT ansId,assmt,ques,answerCode,details
    FROM ayanswer
    INTO OUTFILE 'c:/data/test1.csv'
    FIELDS TERMINATED by ','
    OPTIONALLY ENCLOSED BY '"'
    FIELDS ESCAPED BY '\';

However when I run this statement in mysql I get the following error:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FIELDS ESCAPED BY ”’ at line 9

According to the MySQL Server 8.0 reference manual this syntax should be correct. So what am I doing wrong?

Composer patches cweagans Core module update syntax – one patch not being applied

I’m using cweagans composer patches: https://github.com/cweagans/composer-patches
to patch Drupal 9.x
I’ve made a patch file. The first patch applies but I think I have the path wrong for the core module, layout_builder, which I am trying to patch. Patch file below. The patch seems to be completely ignored. Layout Builder patch is applied to: core/modules/layout_builder/src/Form/OverridesEntityForm.php


{
   "patches": {
     "drupal/imce": {
         "Secuirty isued D9 imcefilefield": "https://www.drupal.org/files/issues/2020-06-25/ImceFileField-3149697-9-D8.patch"
     },
     "core/layout_builder": {
         "Default region for overridden layout of entity": "https://www.drupal.org/files/issues/2019-06-18/3053906-11-default-region-value.patch"
     }
   }
}

vhdl – Beginner: undeclared signal and syntax errors

Very much a beginner in VHDL, I found some code to try and get a board to blink an LED but I decided to try and have it scan across the LED’s instead. I’m getting:

“Syntax error near <=” VHDL 1261 – Line 14
“Syntax error near if” VHDL 1261 – Line 22
“State is not declared” VHDL 1241 – Line 53, Line 54

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

ENTITY CYLON IS
port(
      CLK  : IN  std_logic;
      LED  : OUT std_logic_vector(7 downto 0)
    );
end Cylon;

architecture Cylon_Beh of CYLON is
      constant mx_cnt : natural   := 48000000;
      signal   state  : std_logic <= '0'; --LINE14
      signal   enable : std_logic <= '0';
        
begin
process(CLK)
      variable count  : natural range 0 to mx_cnt;
begin
        --enables count to run
        if rising_edge(clk) then --LINE22
            --enable = 0, state ++
            if count < mx_cnt & enable = 0 then
                count = count + 1;
                --Controls State increment/decrement
                if (mx_cnt % 60000000 = 0) then
                    state = state + 1;
                end if;
            else                
                count  = 0;
                enable = 1;
                state  = state + 1;
            end if;
            
            --enable = 1, state--
            if count < mx_cnt & enable = 1 then
                count = count + 1;
                --Controls State increment/decrement
                if (mx_cnt % 60000000 = 0) then
                    state = state - 1;
                end if;
            else                
                count  = 0;
                enable = 0;
                state  = state + 1;
            end if;
        end if;
end process;

process 
begin
    wait on state; -LINE53
        case state is -LINE54
            when 0 => LED <= "00000001";
            when 1 => LED <= "00000010";
            when 2 => LED <= "00000100";
            when 3 => LED <= "00001000";
            when 4 => LED <= "00010000";
            when 5 => LED <= "00100000";
            when 6 => LED <= "01000000";
            when 7 => LED <= "10000000";
        end case;
end process; 

end Cylon_Beh;  

I Feel I’m very close to getting my result, assuming my logic is right, but I can’t get past these errors. Any wizards out there who can offer more experienced eyes?

externalevaulate – How to assemble Python abstract syntax trees (AST) in Mathematica?

I would like to assemble Python ‘ast.Module‘ objects inside of Mathematica and then submit them to Python via e.g. ExternalEvaluate("exec(astObject)").

The Python ast, parse, eval, exec and compile functions can all operate on ‘ast.Module‘ objects, either outputting them or taking them as inputs. However I don’t know how to assemble this astObject within Mathematica/WL and then send it over to Python via ExternalEvaluate.

I am trying to programmatically generate Python code in MMA (for a genetic algorithm) and then submit it to Python for evaluation. I could assemble Python code strings, but then I have to handle all of the indentation, which seems like a pain.

Is it possible to create this sort of Python object on the Mathematica side?

B

PS: Here is a description of the ‘ast.Module‘ objects: https://greentreesnakes.readthedocs.io/en/latest/tofrom.html

PPS: I have cross-posted this on Wolfram Community: https://community.wolfram.com/groups/-/m/t/2070851

JavaScript syntax: bucketing based on days (today, yesterday and past)

I am trying to create three buckets of objects. Today, yesterday and past. I am wondering can the following be done in a more concise way in pure JavaScript without any libraries?

const (todayBucket, yesterdayBucket) = (0, 1).map(offset =>
  recordings.filter(({ createdOn }) =>
    moment(createdOn).isSame(moment().add(-offset), 'day'),
  ),
);
const pastBucket = recordings.filter(
  recording => !(...todayBucket, ...yesterdayBucket).includes(recording),
);

Dovecot configuration files using `remote` syntax not being honored

According to the Dovecot documentation, one can alter configuration directives based on the protocol, as well as the local and remote IPs.

In my current setup (Mail-in-a-box using Nextcloud, which uses IMAP authentication), my mail logs are spammed with local logins. I really don’t need these reports, but still want to retain login logs for remote IPs.

I set the following in my configuration:

remote 127.0.0.1 {
  info_log_path = /dev/null
}

When I run doveadm -n -f remote=127.0.0.1, this appears to be registered correctly:

# 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.21 (92477967)
...
info_log_path = /dev/null
...
remote 127.0.0.1 {
  info_log_path = /dev/null
}

Unfortunately, I’m still getting spammed with login reports when the local and remote IPs are both localhost.

Aug 12 12:17:13 imap-login: Info: Login: user=<user@domain.tld>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=29798, TLS, session=<FGVJhbCsstt/AAAB>
Aug 12 12:17:13 imap(user@domain.tld): Info: Logged out in=305 out=2277

I’ve also tried logging to a specific file, instead of /dev/null, but no file was created. So there must be an issue with my understanding. Anyone else successfully able to use these conditionals in their configuration?

How to figure out syntax for symbols?

I’m new to Mathematica and am having a hard time figuring out how to type certain symbols when I read the documentation.

For example, in https://reference.wolfram.com/language/ref/MatrixPropertyDistribution.html, the syntax is:

MatrixPropertyDistribution(expr,x mdist) where there is a symbol between x and mdist. I eventually figured out that the symbol could be interpreted as Distributed(x, mdist) or x (Distributed) mdist, but is there a function in Mathematica or some other website (like Detexify for Tex) that can translate the symbol to the thing you would actually need to type in Mathematica to get the symbol?

A similar issue I’m having right now is trying to define the usual complex inner product as is done in first example in the Applications section of this reference: https://reference.wolfram.com/language/ref/Conjugate.html. The issue is that the braces they have there is not the same as just the brackets on the keyboard corresponding to pressing Shift with “,” or Shift with “.” and I’d like to find out how to actually type these certain braces, so I can actually use the inner product.

ssh – could not parse *** as int value for flag port,p: strconv.ParseInt: parsing “***”: invalid syntax

I’m new in Devops. and I’m trying to use CI/CD for a simple Node.js (express.js) project in github actions. And I’m using evennode as my host.
But I’m getting this error in “SSH and deploy node app step” for port:

could not parse *** as int value for flag port,p: strconv.ParseInt:
parsing “***”: invalid syntax

How do I set the port? I’m doing something like this: 22, p: 22, port: 22. But I did not get an answer.

enter image description here