create database name lowcase ?

21 vues
Accéder directement au premier message non lu

lone ois

non lue,
31 mars 2022, 14:39:3231/03/2022
à sqlalchemy
Hi everyone, I have a question

I use Postgresql
Before creating a database, the name is uppercase and lowercase, and there is no problem.

Later SQLAlchemy was updated to version 1.4
Don't know when the version started,
When creating a database again, use uppercase and lowercase names, which will always be lowercase database names.
As a result, using drop database will fail.

I am currently using:
Arch-linux
postgresql  V13.6-1
sqlalcgemy V1.4.33
pyscopg2    V2.93
dictalchemy3 V1.0.0

E.g :
engine = sqlalchemy.create_engine(
    "postgresql://xxx:yyy@localhost/postgres"
)
conn = engine.connect()
conn.execute( "commit" )
stt = "CREATE DATABASE ABCDEF"
conn.execute(stt)
conn.close()

===============
The database name will become abcdef

I'm not sure if this is the reason for sqlalchemy or pyscopg2 ?

Thank you everyone.

Jonathan Vanasco

non lue,
31 mars 2022, 16:47:5231/03/2022
à sqlalchemy
I'm not aware of any recent changes in the libraries that would cause that behavior.

It may be how you are using the libraries or raw sql.

PostgreSQL will convert database names to lowercase UNLESS the database name is in quotes.

These will all create `abc`:

    CREATE DATABASE abc;
    CREATE DATABASE Abc;
    CREATE DATABASE ABc;
    CREATE DATABASE ABC;
    CREATE DATABASE aBc;
    CREATE DATABASE aBC;
    CREATE DATABASE abC;

These will create two different databases:

    CREATE DATABASE "abc";
    CREATE DATABASE "Abc";
    CREATE DATABASE "ABc";
    CREATE DATABASE "ABC";
    .. etc.. 


oislone

non lue,
31 mars 2022, 22:01:2731/03/2022
à 'Jonathan Vanasco' via sqlalchemy

I see.
I didn't expect it to be so simple.
I tried to debug sqlalchemy, but didn't find character conversion
It turned out to be the default way of postgreql.
Thanks for your instruction.

Massimiliano della Rovere

non lue,
1 avr. 2022, 01:46:1901/04/2022
à sqlal...@googlegroups.com
Postgresql is case case insensitive unless you impose a specific casing using " (double quotes): they are valid everywhere postgresql expects an identifier (schema name, table name, column name, cte name, after AS, etc.

So it's all correct.



--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
http://www.sqlalchemy.org/
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/89e4aa92-c9c2-767d-6caf-dc0b77477a2a%40gmail.com.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message