question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Naming of columns

See original GitHub issue

Discussed in https://github.com/piccolo-orm/piccolo/discussions/206

Allow Table columns to map to database columns with different names.

For example:

class MyTable(Table):
    name = Varchar(name="person_name")

In the example above, when doing queries, you will use MyTable.name, but the actual column in the database is called person_name.

This is useful when using Piccolo on legacy databases with non-ideal column names.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
gmoscommented, Oct 5, 2021

Just installed the new version. Works perfectly. Thnx.

0reactions
dantownsendcommented, Oct 5, 2021

There’s also this approach for anyone coming across this in the future:

https://github.com/piccolo-orm/piccolo/blob/69389132d5946ea29f98a763d015afe49fbc5b86/piccolo/table.py#L955

So it’s:

from piccolo.table import create_table_class

LoraKey = create_table_class(
    class_kwargs={'tablename': 'copy_lora_key', 'db': DB},
    class_members={'class': Varchar(null=False, length=1)}
)

A bit harder to read, but useful in a pinch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database, Table and Column Naming Conventions
Step-1 : Each column name should be unique. If two columns from different tables serving different purposes are in the same database then...
Read more >
How to Give a Name to the Columns in Excel
1. Click the letter of the column you want to rename to highlight the entire column. ; 2. Click the "Name" box, located...
Read more >
Learn SQL: Naming Conventions - SQLShack
A naming convention is a set of unwritten rules you should use if you want to increase the readability of the whole data...
Read more >
SQL Naming Conventions (2023 Tutorial & Examples)
Use all lowercase for column and table names and to separate words with an underscore (“_”). For example, start_date and end_date as column...
Read more >
Rules for name column definitions - IBM
Column names can be up to 255 characters long. · They must begin with an alphabetic character, $ or underscore, and can contain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found